# yum module localinstall many rpms from directory possible?

**URL:** <https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565>\
**Category:** Ansible Project\
**Created:** [September 21, 2017, 6:51pm UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565 "2017-09-21T18:51:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daddyocruzer](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@daddyocruzer](https://forum.ansible.com/u/daddyocruzer)\
**Post date:** [September 21, 2017, 6:51pm UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565/1 "2017-09-21T18:51:02Z")

</div>

Hello

tasks:

- name: yum local install  
yum: name=/sharedfilesystem/\*.rpm state=present

Our team has several environments that lead up to our production environment, so patches must be applied and tested in one environment at a time (as they exist at a specific version ‘point-in-time’) so I can’t do a blind yum update latest in our production environment – therefore, I download the latest available at a point-in-time and apply them to each environment only once testing has succeeded in the previous environment.

Can ansible yum module help ‘localinstall’ patches that have been pre-downloaded? (I’ve only seen yum module work with a single rpm)

Maybe should be using command instead of yum module?

---

<div class="post-metadata">

**Author:** ![Dick\_Davies](https://avatars.discourse-cdn.com/v4/letter/d/b9e5f3/32.png) [@Dick\_Davies](https://forum.ansible.com/u/Dick_Davies)\
**Post date:** [September 21, 2017, 7:37pm UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565/2 "2017-09-21T19:37:07Z")

</div>

That's fine, look at with\_items to get it all done in a single yum transaction.

---

<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:** [September 21, 2017, 7:49pm UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565/3 "2017-09-21T19:49:42Z")

</div>

The name support a list or comma separated listing.

So you could do something like this:

&nbsp;&nbsp;&nbsp;- find:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;paths: /sharedfilesystem  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;patterns: '\*.rpm'  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;register: r

&nbsp;&nbsp;&nbsp;- yum:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ r.files | map(attribute='path') | list }}"

---

<div class="post-metadata">

**Author:** ![daddyocruzer](https://avatars.discourse-cdn.com/v4/letter/d/838e76/32.png) [@daddyocruzer](https://forum.ansible.com/u/daddyocruzer)\
**Post date:** [September 22, 2017, 12:00am UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565/4 "2017-09-22T00:00:30Z")

</div>

Success !!!

Some Learning Assumptions:

---

<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:** [September 22, 2017, 7:20am UTC](https://forum.ansible.com/t/yum-module-localinstall-many-rpms-from-directory-possible/25565/5 "2017-09-22T07:20:05Z")

</div>

> Success !!!!
> 
> # Some Learning Assumptions:
> 
> So, this section I think I kinda get - it sets up 'r' to iterate through  
> the 'patterns' matches found beneath 'paths'.

register: r register the output of the find in the variable called r.  
r can be anything, like result.

To see what the variable r contains you can use debug.

- debug: var=r

One of the returns is files, files is a list of all files find found.  
Each list is a array with a lot of information about the file.

If you only want to show this list you can use debug

- debug: var=r.files

> &nbsp;&nbsp;- yum:  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;name: "{{ r.files | map(attribute='path') | list }}"

As you can see if you run the debug above you'll see that each list item has many attributes, one of them is path.  
Map filter gather all of them for each entry in the list r.files.

Map returns a object as you can see with

- debug: var="r.files | map(attribute='path')"

so we need to filter it to something useful, and since the yum module support list we make it a list.

- debug: var="r.files | map(attribute='path') | list"

Another use of debug is with msg.

- debug: msg="All files in a list - {{ r.files | map(attribute='path') | list }}"

> This must iterate through each match and install it? Assumptions:
> 
> &nbsp;&nbsp;&nbsp;- Install must be a default, since there's no sign of it.  
> &nbsp;&nbsp;&nbsp;- map(attribute='path' expands to the absolute path of where the match  
> &nbsp;&nbsp;&nbsp;is?  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- if so, why is path singlular here, and 'paths' plural is used  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;above?  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- how is all this done on a 'name' line? because default yum  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;behavior is install local...?  
> &nbsp;&nbsp;&nbsp;- list iterates through matches registered to 'r' lets yum default  
> &nbsp;&nbsp;&nbsp;install it?

I think the above answer all the questions.
