diff mbox series

[6/6] codereadyrepo: Enable codeready-builder in AWS

Message ID 20241210192920.682914-7-cel@kernel.org (mailing list archive)
State New
Headers show
Series Recent fixes | expand

Commit Message

Chuck Lever Dec. 10, 2024, 7:29 p.m. UTC
From: Chuck Lever <chuck.lever@oracle.com>

Running "make pynfs" against an AWS EC2 instance fails with:

  Error: No matching repo to modify: codeready-builder-for-rhel-9-x86_64-rpms.

Adjust the logic in the codereadyrepo playbook to sketch in what
might be needed for running the pynfs workflow in AWS.

Similar adjustments might be necessary for other cloud providers.

Signed-off-by: Chuck Lever <chuck.lever@oracle.com>
---
 .../roles/codereadyrepo/defaults/main.yml     |  5 +++
 playbooks/roles/codereadyrepo/tasks/main.yml  | 41 +++++++++++++++----
 2 files changed, 37 insertions(+), 9 deletions(-)
 create mode 100644 playbooks/roles/codereadyrepo/defaults/main.yml
diff mbox series

Patch

diff --git a/playbooks/roles/codereadyrepo/defaults/main.yml b/playbooks/roles/codereadyrepo/defaults/main.yml
new file mode 100644
index 000000000000..1f1f64facf90
--- /dev/null
+++ b/playbooks/roles/codereadyrepo/defaults/main.yml
@@ -0,0 +1,5 @@ 
+# SPDX-License-Identifier GPL-2.0+
+---
+# Our sensible defaults for the codereadyrepo role.
+
+kdevops_enable_terraform: false
diff --git a/playbooks/roles/codereadyrepo/tasks/main.yml b/playbooks/roles/codereadyrepo/tasks/main.yml
index 71ad05c9d539..90e0bbf3d332 100644
--- a/playbooks/roles/codereadyrepo/tasks/main.yml
+++ b/playbooks/roles/codereadyrepo/tasks/main.yml
@@ -1,14 +1,37 @@ 
 ---
-- name: Enable the CodeReady repo
-  become: yes
-  ansible.builtin.command: /usr/bin/dnf config-manager --enable codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms
+- name: Select the CodeReady repo to enable (RHEL AWS)
+  ansible.builtin.set_fact:
+    codeready_repo: "codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-rhui-rpms"
   when:
-    - ansible_distribution == 'RedHat'
-    - not devconfig_custom_yum_repofile
+    - kdevops_enable_terraform
+    - kdevops_terraform_provider == "aws"
+    - ansible_distribution == "RedHat"
 
-- name: Enable the CodeReady repo
-  become: yes
-  ansible.builtin.command: /usr/bin/dnf config-manager --enable crb
+- name: Select the CodeReady repo to enable (RHEL)
+  ansible.builtin.set_fact:
+    codeready_repo: "codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms"
+  when:
+    - not kdevops_enable_terraform
+    - ansible_distribution == "RedHat"
+
+- name: Select the CodeReady repo to enable (CentOS)
+  ansible.builtin.set_fact:
+    codeready_repo: "crb"
+  when:
+    - not kdevops_enable_terraform
+    - ansible_distribution == "CentOS"
+
+- name: Enable the selected CodeReady repo
+  become: true
+  become_method: ansible.builtin.sudo
+  ansible.builtin.command:
+    argv:
+      - "/usr/bin/dnf"
+      - "config-manager"
+      - "--enable"
+      - "{{ codeready_repo }}"
+  register: dnf_result
   when:
-    - ansible_distribution == 'CentOS'
     - not devconfig_custom_yum_repofile
+    - ansible_distribution == "RedHat" or ansible_distribution == "CentOS"
+  changed_when: dnf_result is success