@@ -1,14 +1,28 @@
---
-- 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 RHEL CodeReady Builder repo
+ ansible.builtin.set_fact:
+ codeready_repo: "codeready-builder-for-rhel-{{ ansible_distribution_major_version }}-{{ ansible_architecture }}-rpms"
when:
- ansible_distribution == 'RedHat'
- not devconfig_custom_yum_repofile
-- name: Enable the CodeReady repo
- become: yes
- ansible.builtin.command: /usr/bin/dnf config-manager --enable crb
+- name: Select the CentOS CodeReady Builder repo
+ ansible.builtin.set_fact:
+ codeready_repo: "crb"
when:
- ansible_distribution == 'CentOS'
- not devconfig_custom_yum_repofile
+
+- name: Enable the selected CodeReady Builder repo
+ become: true
+ become_method: ansible.builtin.sudo
+ ansible.builtin.command:
+ argv:
+ - "/usr/bin/dnf"
+ - "config-manager"
+ - "--enable"
+ - "{{ codeready_repo }}"
+ register: dnf_result
+ when:
+ - codeready_repo is defined
+ changed_when: dnf_result is success