# yum repolist -v Output to Vars/Dict and use the data

**URL:** <https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697>\
**Category:** Ansible Project\
**Created:** [April 16, 2020, 10:19am UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697 "2020-04-16T10:19:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Spoonless](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Spoonless](https://forum.ansible.com/u/Spoonless)\
**Post date:** [April 16, 2020, 10:19am UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/1 "2020-04-16T10:19:33Z")

</div>

Hi all,

I am having some difficulty in getting my head around the use of variables, facts and dicts.

The Ansible yum module does not give me output from an equivalent yum repolist -v command, so I am using shell for that.

This is what I am trying to do:

yum repolist -v will give me a list of the enabled repos on a system, for example:

Repo-id : jenkins  
Repo-name : Jenkins-stable  
Repo-revision: 1585146777  
Repo-updated : Wed Mar 25 15:32:57 2020  
Repo-pkgs : 102  
Repo-size : 6.1 G  
Repo-baseurl : [Redhat Jenkins Packages](http://pkg.jenkins.io/redhat-stable/)  
Repo-expire : 21,600 second(s) (last: Tue Apr 14 08:28:35 2020)  
Filter : read-only:present  
Repo-filename: /etc/yum.repos.d/jenkins.repo

Repo-id : mongodb-org-4.2/7  
Repo-name : MongoDB Repository  
Repo-revision: 1585187010  
Repo-updated : Thu Mar 26 02:43:32 2020  
Repo-pkgs : 25  
Repo-size : 543 M  
Repo-baseurl : [MongoDB Repositories](https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/)  
Repo-expire : 21,600 second(s) (last: Tue Apr 14 08:28:36 2020)  
Filter : read-only:present  
Repo-filename: /etc/yum.repos.d/mongodb-org-4.2.repo

I want to:  
1: register, lets say for now, the Repo-id, Repo-name, Repo-baseurl, Repo-filename to variable/s, or a dictionary, not sure here ?.  
2: Check if the Repo-baseurl of a Repo-id contains a certain url, if it does, register another variable, illegalurl = 1, for that Repo  
3: Grab the Repo-filename where the Repo-baseurl illegalurl is 1  
4: Do something with that file:  
b: Check if a repo file exists in a different location with a correct Repo-baseurl  
c: Change the Repo-baseurl in the originating .repo file.  
== I guess, if I have the variables, dictionary, facts of the individual blocks of data, then I can use them to do other tasks that I need.

I have tried:

Individual tasks to grab the data and register a variable:  
example:

tasks:

- name: Collect Repo id from yum repolist -v  
shell: “yum repolist -v | grep Repo-id | awk -F": " ‘{print $2}’”  
register: echo\_repoids

# - debug:

# var: echo\_repoids.stdout\_lines

- name: Collect Repo Name from yum repolist -v  
shell: “yum repolist -v | grep Repo-name | awk -F": " ‘{print $2}’”  
register: echo\_reponame

# - debug:

# var: echo\_reponame.stdout\_lines

- name: Collect Repo base url from yum repolist -v  
shell: “yum repolist -v | grep Repo-baseurl | awk -F": " ‘{print $2}’”  
register: echo\_repobaseurl

# - debug:

# var: echo\_repobaseurl.stdout\_lines

- name: Collect Repo filename from yum repolist -v  
shell: “yum repolist -v | grep Repo-filename | awk -F": " ‘{print $2}’”  
register: echo\_repofilename

# - debug:

# var: echo\_repofilename.stdout\_lines

I also tried:

tasks:

- name: Collect the enabled Repo information  
shell: “yum repolist -v | grep {{item}} | awk -F": " ‘{print $2}’”  
with\_items:
- “Repo-id”
- “Repo-name”
- “Repo-baseurl”
- “Repo-filename”  
register: output

# debug: var=output

But I do not know how to match the blocks contents of Repo-id, Repo-name, Repo-baseurl, Repo-filename as keys and values so I can use them later in the tasks/ playbooks.

I hope that helps you to understand what I am trying to accomplish.

Thanks in advance for any advice anyone can offer. 🙂  
Best Regards.

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 16, 2020, 11:55am UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/2 "2020-04-16T11:55:19Z")

</div>

> This is what I am trying to do:
> 
> yum repolist -v will give me a list of the enabled repos on a system, for  
> example:
> 
> Repo-id : jenkins  
> Repo-name : Jenkins-stable  
> Repo-revision: 1585146777  
> Repo-updated : Wed Mar 25 15:32:57 2020  
> Repo-pkgs : 102  
> Repo-size : 6.1 G  
> Repo-baseurl : [http://pkg.jenkins.io/redhat-stable/](http://pkg.jenkins.io/redhat-stable/)  
> Repo-expire : 21,600 second(s) (last: Tue Apr 14 08:28:35 2020)  
> &nbsp;&nbsp;Filter : read-only:present  
> Repo-filename: /etc/yum.repos.d/jenkins.repo
> 
> Repo-id : mongodb-org-4.2/7  
> Repo-name : MongoDB Repository  
> Repo-revision: 1585187010  
> Repo-updated : Thu Mar 26 02:43:32 2020  
> Repo-pkgs : 25  
> Repo-size : 543 M  
> Repo-baseurl : [https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86\_64/](https://repo.mongodb.org/yum/redhat/7/mongodb-org/4.2/x86_64/)  
> Repo-expire : 21,600 second(s) (last: Tue Apr 14 08:28:36 2020)  
> &nbsp;&nbsp;Filter : read-only:present  
> Repo-filename: /etc/yum.repos.d/mongodb-org-4.2.repo
> 
> I want to:  
> 1: register, lets say for now, the Repo-id, Repo-name, Repo-baseurl,  
> Repo-filename to variable/s, or a dictionary, not sure here ?.  
> 2: Check if the Repo-baseurl of a Repo-id contains a certain url, if it  
> does, register another variable, illegalurl = 1, for that Repo  
> 3: Grab the Repo-filename where the Repo-baseurl illegalurl is 1  
> 4: Do something with that file:  
> &nbsp;&nbsp;a: Generate a mail with that information  
> &nbsp;&nbsp;b: Check if a repo file exists in a different location with a correct  
> Repo-baseurl  
> &nbsp;&nbsp;c: Change the Repo-baseurl in the originating .repo file.  
> &nbsp;&nbsp;== I guess, if I have the variables, dictionary, facts of the individual  
> blocks of data, then I can use them to do other tasks that I need.
> 
> I have tried:
> 
> Individual tasks to grab the data and register a variable:  
> example:
> 
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Collect Repo id from yum repolist -v  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: "yum repolist -v | grep Repo-id | awk -F\": \" '{print $2}'"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: echo\_repoids  
> # - debug:  
> # var: echo\_repoids.stdout\_lines
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Collect Repo Name from yum repolist -v  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: "yum repolist -v | grep Repo-name | awk -F\": \" '{print $2}'"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: echo\_reponame  
> # - debug:  
> # var: echo\_reponame.stdout\_lines
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Collect Repo base url from yum repolist -v  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: "yum repolist -v | grep Repo-baseurl | awk -F\": \" '{print  
> $2}'"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: echo\_repobaseurl  
> # - debug:  
> # var: echo\_repobaseurl.stdout\_lines
> 
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Collect Repo filename from yum repolist -v  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: "yum repolist -v | grep Repo-filename | awk -F\": \" '{print  
> $2}'"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: echo\_repofilename  
> # - debug:  
> # var: echo\_repofilename.stdout\_lines

If you use \<variable\>.stdout you get the value, .stdout\_lines is a list where  
the first line is the first element, so you would need to use  
\<variable\>.stdout\_lines.0

> I also tried:
> 
> &nbsp;&nbsp;tasks:  
> &nbsp;&nbsp;&nbsp;&nbsp;- name: Collect the enabled Repo information  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;shell: "yum repolist -v | grep {{item}} | awk -F\": \" '{print $2}'"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;with\_items:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "Repo-id"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "Repo-name"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "Repo-baseurl"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- "Repo-filename"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: output  
> # debug: var=output

Since you run this in a loop, the result is in results.

Repo-id is output.results.0.stdout  
Repo-name is output.results.1.stdout  
and so on

> But I do not know how to match the blocks contents of Repo-id, Repo-name,  
> Repo-baseurl, Repo-filename as keys and values so I can use them later in  
> the tasks/ playbooks.

You could just use the variables as shown above. You could use set\_fact to  
create new variable. Something like this for the last example.

- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;repoid: "{{ output.results.0.stdout }}"  
&nbsp;&nbsp;&nbsp;&nbsp;reponame: "{{ output.results.1.stdout }}"

---

<div class="post-metadata">

**Author:** ![Spoonless](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Spoonless](https://forum.ansible.com/u/Spoonless)\
**Post date:** [April 17, 2020, 8:23am UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/3 "2020-04-17T08:23:41Z")

</div>

Hi,

Thanks for the tip in the right direction:

Here is what I have so far…  
But, my Debug output is showing me all of the repo’s and not filtering. ?

```auto
tasks:
    - name: Set the required enabled repo information as facts
      shell: "yum repolist -v | grep {{item}} | awk -F\": \" '{print $2}'"
      with_items:
        - "Repo-id"
        - "Repo-name"
        - "Repo-baseurl"
        - "Repo-filename"
      register: output      
    - set_fact:
        repoid: "{{ output.results.0.stdout }}"
        reponame: "{{ output.results.1.stdout }}"
        repobaseurl: "{{ output.results.2.stdout }}"
        repofilename: "{{ output.results.3.stdout }}"

    - debug:
        msg: "{{reponame}} is an illegal url"
      when: repobaseurl is search("ftp://somehostname.*")

===

```

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 20, 2020, 9:26pm UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/4 "2020-04-20T21:26:34Z")

</div>

Yes, the stdout will contain everything.

output.results.0.stdout\_lines.0 will contain the repo-id for the first one.  
output.results.0.stdout\_lines.1 will contain the repo-id for the second one.

output.results.5.stdout\_lines.0 will contain the repo-baseurl for the first one.  
output.results.5.stdout\_lines.1 will contain the repo-baseurl for the second one.

It isn't easy to parse text in Ansible, i would create a script that did the  
parsing and returned a json that you can use a lot easier in Ansible.

---

<div class="post-metadata">

**Author:** ![Spoonless](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Spoonless](https://forum.ansible.com/u/Spoonless)\
**Post date:** [April 21, 2020, 9:01am UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/5 "2020-04-21T09:01:00Z")

</div>

Hi,

So, if I get the output of my yum repolist -v to a json format then I can use the json query in Ansible, like here:

[https://docs.ansible.com/ansible/latest/user\_guide/playbooks\_filters.html#json-query-filter](https://docs.ansible.com/ansible/latest/user_guide/playbooks_filters.html#json-query-filter)

I guess, Python or jq or something to prep the output in the required format.  
(I’ll have to get to grips with that part.)

Thanks again.

---

<div class="post-metadata">

**Author:** ![Spoonless](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Spoonless](https://forum.ansible.com/u/Spoonless)\
**Post date:** [April 21, 2020, 5:00pm UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/6 "2020-04-21T17:00:52Z")

</div>

Trying to get the yum repolist -v data to a json format that I can parse with Ansible is tricky enough for a beginner.

---

<div class="post-metadata">

**Author:** ![Spoonless](https://avatars.discourse-cdn.com/v4/letter/s/45deac/32.png) [@Spoonless](https://forum.ansible.com/u/Spoonless)\
**Post date:** [April 21, 2020, 7:14pm UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/7 "2020-04-21T19:14:43Z")

</div>

If I am correct, I would need the output from yum repolist -v :

Loading “fastestmirror” plugin  
Loading “langpacks” plugin  
Adding en\_US.UTF-8 to language list  
Config time: 0.008  
Yum version: 3.4.3  
Loading mirror speeds from cached hostfile  
Setting up Package Sacks  
pkgsack time: 0.008

Repo-id : docker-ce-stable/x86\_64  
Repo-name : Docker CE Stable - x86\_64  
Repo-revision: 1583949071  
Repo-updated : Wed Mar 11 18:51:11 2020  
Repo-pkgs : 70  
Repo-size : 1.6 G  
Repo-baseurl : [https://download.docker.com/linux/centos/7/x86\_64/stable/](https://download.docker.com/linux/centos/7/x86_64/stable/)  
Repo-expire : 21,600 second(s) (last: Tue Apr 21 11:06:47 2020)  
Filter : read-only:present  
Repo-filename: /etc/yum.repos.d/docker-ce.repo

Repo-id : jenkins  
Repo-name : Jenkins-stable  
Repo-revision: 1585146777  
Repo-updated : Wed Mar 25 15:32:57 2020  
Repo-pkgs : 102  
Repo-size : 6.1 G  
Repo-baseurl : [http://pkg.jenkins.io/redhat-stable/](http://pkg.jenkins.io/redhat-stable/)  
Repo-expire : 21,600 second(s) (last: Tue Apr 21 11:06:48 2020)  
Filter : read-only:present  
Repo-filename: /etc/yum.repos.d/jenkins.repo

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [April 21, 2020, 9:01pm UTC](https://forum.ansible.com/t/yum-repolist-v-output-to-vars-dict-and-use-the-data/32697/8 "2020-04-21T21:01:58Z")

</div>

> If I am correct, I would need the output from yum repolist -v :
> 
> Loading "fastestmirror" plugin  
> Loading "langpacks" plugin  
> Adding en\_US.UTF-8 to language list  
> Config time: 0.008  
> Yum version: 3.4.3  
> Loading mirror speeds from cached hostfile  
> Setting up Package Sacks  
> pkgsack time: 0.008
> 
> Repo-id : docker-ce-stable/x86\_64  
> Repo-name : Docker CE Stable - x86\_64  
> Repo-revision: 1583949071  
> Repo-updated : Wed Mar 11 18:51:11 2020  
> Repo-pkgs : 70  
> Repo-size : 1.6 G  
> Repo-baseurl : [https://download.docker.com/linux/centos/7/x86\_64/stable/](https://download.docker.com/linux/centos/7/x86_64/stable/)  
> Repo-expire : 21,600 second(s) (last: Tue Apr 21 11:06:47 2020)  
> &nbsp;&nbsp;Filter : read-only:present  
> Repo-filename: /etc/yum.repos.d/docker-ce.repo
> 
> Repo-id : jenkins  
> Repo-name : Jenkins-stable  
> Repo-revision: 1585146777  
> Repo-updated : Wed Mar 25 15:32:57 2020  
> Repo-pkgs : 102  
> Repo-size : 6.1 G  
> Repo-baseurl : [http://pkg.jenkins.io/redhat-stable/](http://pkg.jenkins.io/redhat-stable/)  
> Repo-expire : 21,600 second(s) (last: Tue Apr 21 11:06:48 2020)  
> &nbsp;&nbsp;Filter : read-only:present  
> Repo-filename: /etc/yum.repos.d/jenkins.repo
> 
> ==  
> To look like this as a json file:
> 
> {  
> &nbsp;&nbsp;&nbsp;&nbsp;"repos": [  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid\_ref": "docker-ce-stable/x86\_64",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame\_ref": "Docker CE Stable - x86\_64"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid\_ref": "jenkins",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame\_ref": "Jenkins-stable"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;&nbsp;&nbsp;],  
> &nbsp;&nbsp;&nbsp;&nbsp;"repoinfo": [  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid": "docker-ce-stable/x86\_64",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame": "Docker CE Stable - x86\_64",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoupdated": "Wed Mar 11 18:51:11 2020",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repopkgs": "70",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reposize": "1.6 G",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repobaseurl":  
> "[https://download.docker.com/linux/centos/7/x86\_64/stable/&quot;](https://download.docker.com/linux/centos/7/x86_64/stable/&quot;),  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repofilename": "/etc/yum.repos.d/docker-ce.repo",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid\_ref": "docker-ce-stable/x86\_64",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame\_ref": "Docker CE Stable - x86\_64"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;},  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid": "jenkins",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame": "Jenkins-stable",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoupdated": "Wed Mar 25 15:32:57 2020",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repopkgs": "102",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reposize": "6.1 G",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repobaseurl": "[http://pkg.jenkins.io/redhat-stable/&quot;](http://pkg.jenkins.io/redhat-stable/&quot;),  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repofilename": "/etc/yum.repos.d/jenkins.repo",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"repoid\_ref": "jenkins",  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"reponame\_ref": "Jenkins-stable"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;}  
> &nbsp;&nbsp;&nbsp;&nbsp;]  
> }

No, repos should be a list with only 2 element.

> Any reasonable tips on doing that. ?

That is way out of the scope for this list, you should find some other  
community to help with text parsing.

That being said, I had 20 minutes before bedtime I needed to kill I created this crude  
thing that probably breaks between different yum versions.

I'm not going to explain how it work since this group is not the place for that.  
Use it if it works or try to fix it yourself if it don't

Since the output of yum repolist is more or less yaml, it's a lot easier to  
convert it to yaml than json.

&nbsp;&nbsp;- shell: yum repolist -v | sed -e '1,/Repo-filename/d' | head -n -2 | sed -e 's/^ \+//' -e 's/ \+:/:/' -e 's/^/ /' -e 's/^ Repo-id/- Repo-id/' -e 's/:\s/:/2g'  
&nbsp;&nbsp;&nbsp;&nbsp;register: r

&nbsp;&nbsp;- set\_fact:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;repos: '{{ r.stdout | from\_yaml }}'

&nbsp;&nbsp;- debug: var=repos  
&nbsp;&nbsp;- debug: var=repos[0]['Repo-id']
