Skip to content

Commit 69bb0dc

Browse files
committed
codereadyrepo: Refactor to prepare for more complex usage scenarios
I'm about to add a few more cases that the codereadyrepo role needs to handle. The only difference for all of these cases is the name of the repo to enable, so pull out the selection of that name, then do the repo enablement task only when a repo name was found. Signed-off-by: Chuck Lever <[email protected]>
1 parent 6779105 commit 69bb0dc

File tree

1 file changed

+20
-6
lines changed
  • playbooks/roles/codereadyrepo/tasks

1 file changed

+20
-6
lines changed
Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,28 @@
11
---
2-
- name: Enable the CodeReady repo
3-
become: yes
4-
ansible.builtin.command: /usr/bin/dnf config-manager --enable codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms
2+
- name: Select the RHEL CodeReady Builder repo
3+
ansible.builtin.set_fact:
4+
codeready_repo: "codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms"
55
when:
66
- ansible_distribution == 'RedHat'
77
- not devconfig_custom_yum_repofile
88

9-
- name: Enable the CodeReady repo
10-
become: yes
11-
ansible.builtin.command: /usr/bin/dnf config-manager --enable crb
9+
- name: Select the CentOS CodeReady Builder repo
10+
ansible.builtin.set_fact:
11+
codeready_repo: "crb"
1212
when:
1313
- ansible_distribution == 'CentOS'
1414
- not devconfig_custom_yum_repofile
15+
16+
- name: Enable the selected CodeReady Builder repo
17+
become: true
18+
become_method: ansible.builtin.sudo
19+
ansible.builtin.command:
20+
argv:
21+
- "/usr/bin/dnf"
22+
- "config-manager"
23+
- "--enable"
24+
- "{{ codeready_repo }}"
25+
register: dnf_result
26+
when:
27+
- codeready_repo is defined
28+
changed_when: dnf_result is success

0 commit comments

Comments
 (0)