I am creating .repo files using the below code in a yum ansible role. Though I mentioned sslverify as true/false it’s adding as 0 or 1. But in Ansible docs also it’s mentioned as true or false.
Also, it’s adding an extra blank line at the end and also not adding parameters in the order I mentioned.
- name: Create YUM repositories from dictionary
ansible.builtin.yum_repository:
name: "{{ item.value.name }}"
description: "{{ item.value.name }}"
baseurl: "{{ item.value.repository_server }}{{ item.value.baseurl }}"
gpgcheck: "{{ item.value.gpgcheck }}"
gpgkey: "{{ (item.value.repository_server + item.value.gpgkey) if item.value.gpgkey is defined else omit }}"
enabled: yes
sslverify: "{{ item.value.sslverify | ternary('yes', 'no') }}"
loop: "{{ rockyglobal | dict2items }}"
loop_control:
loop_var: item
label: "{{ item.key }}"
variables:
rockyglobal:
testrocky:
name: testrocky
repository_server: https://example.com/artifactory/
baseurl: scgp-repos-rpm-rocky92
gpgcheck: yes
gpgkey: scgp-repos-key
sslverify: true
testrocky_2023_q2:
name: testrocky_2023_q2
repository_server: https://example.com/artifactory/
baseurl: scgp-repos-rpm-x86_64/os/
gpgcheck: yes
gpgkey: scgp-repos-key
sslverify: true
Result:
cat testrocky_2023_q2.repo
[testrocky_2023_q2]
baseurl = https://example.com/artifactory/scgp-repos-rpm-x86_64/os/
enabled = 1
gpgcheck = 1
gpgkey = https://example.com/artifactory/scgp-repos-key
name = testrocky_2023_q2
sslverify = 1
Please Advise!