# Need help on Ansbile yum\_repository bultin module

**URL:** <https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763>\
**Category:** Get Help\
**Tags:** yum, ansible-core\
**Created:** [June 25, 2024, 7:52am UTC](https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763 "2024-06-25T07:52:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krishna2092](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/krishna2092/32/2658_2.png) [@Krishna2092](https://forum.ansible.com/u/Krishna2092)\
**Post date:** [June 25, 2024, 7:52am UTC](https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763/1 "2024-06-25T07:52:35Z")

</div>

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.

```auto
- 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:

```auto
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:

```auto
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!

---

<div class="post-metadata">

**Author:** ![mkrizek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mkrizek/32/2055_2.png) [@mkrizek](https://forum.ansible.com/u/mkrizek)\
**Post date:** [June 25, 2024, 8:11am UTC](https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763/2 "2024-06-25T08:11:40Z")

</div>

> [@Krishna2092](#):
>
> Though I mentioned sslverify as true/false it’s adding as 0 or 1

The module does the conversion automatically. I believe both integer and bool versions are valid.

> [@Krishna2092](#):
>
> not adding parameters in the order I mentioned.

In the documentation it is explicitly mentioned that the parameters are ordered alphabetically, see [ansible.builtin.yum\_repository module – Add or remove YUM repositories — Ansible Community Documentation](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/yum_repository_module.html).

In any case, none of these should affect the correctness of the generated configuration. Is that not a case?

If you want the style of the configuration to be generated differently you would have to use a different module, perhaps `ini`, or a template.

---

<div class="post-metadata">

**Author:** ![Krishna2092](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/krishna2092/32/2658_2.png) [@Krishna2092](https://forum.ansible.com/u/Krishna2092)\
**Post date:** [June 25, 2024, 8:58am UTC](https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763/3 "2024-06-25T08:58:09Z")

</div>

Thanks a lot, @mkrizek. Now I am seeing about the order of attributes. But not sure if both integer and bool versions are valid or not since I am not able to find documentation about that.

Also, is there any specific reason it’s adding an extra blank line at the end?

---

<div class="post-metadata">

**Author:** ![mkrizek](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/mkrizek/32/2055_2.png) [@mkrizek](https://forum.ansible.com/u/mkrizek)\
**Post date:** [June 25, 2024, 9:53am UTC](https://forum.ansible.com/t/need-help-on-ansbile-yum-repository-bultin-module/6763/4 "2024-06-25T09:53:15Z")

</div>

> [@Krishna2092](#):
>
> Also, is there any specific reason it’s adding an extra blank line at the end?

That is the behavior of `configparser.RawConfigParser` that implements the underlying functionality of handling INI files in the module - the blank line is a delimiter between individual sections; it does not seem to care for a situation where there is only one section and puts the delimiter in such a case as well.
