# Yum Local Install Variable

**URL:** <https://forum.ansible.com/t/yum-local-install-variable/14152>\
**Category:** Ansible Project\
**Created:** [December 13, 2013, 5:17pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152 "2013-12-13T17:17:14Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 13, 2013, 5:17pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/1 "2013-12-13T17:17:14Z")

</div>

All;

I am building an RPM for a machine using rpm-build. I then need to take the rpm it built, and I want to use yum to install that. Below is my .yml playbook and the error that accompanies trying to install it. Any thoughts would be greatly appreciated. Thanks!!

32 - name: retrieve rpmbuild file  
33 shell: ls /root/rpmbuild/RPMS/x86\_64/iomemory-vsl-$(uname -r)\*.rpm  
34 register: fusionIORPM  
35 tags:  
36 - fusionIO2  
37  
38 - name: install rpm  
39 yum: name={{ fusionIORPM.stdout\_lines }} state=present  
40 tags:  
41 - fusionIO2

TASK: [server1 | retrieve rpmbuild file] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
changed: [server1]

TASK: [server1 | install rpm] \*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*\*  
failed: [server1] =\> {“failed”: true, “item”: “”}  
msg: Error from repoquery: [‘/usr/bin/repoquery’, ‘–show-duplicates’, ‘–plugins’, ‘–quiet’, ‘-q’, ‘–disablerepo=\*’, ‘–pkgnarrow=installed’, ‘–qf’, ‘%{name}-%{version}-%{release}.%{arch}’, ‘[u/root/rpmbuild/RPMS/x86\_64/iomemory-vsl-2.6.32-431.el6.x86\_64-2.3.11.183-1.0.el6.x86\_64.rpm]’]: Traceback (most recent call last):  
File “/usr/bin/repoquery”, line 1241, in   
main(sys.argv)  
File “/usr/bin/repoquery”, line 1235, in main  
repoq.runQuery(regexs)  
File “/usr/bin/repoquery”, line 805, in runQuery  
pkgs = self.matchPkgs(items, plain\_pkgs=plain\_pkgs)  
File “/usr/bin/repoquery”, line 742, in matchPkgs  
pkgs = self.returnPkgList(patterns=items)  
File “/usr/bin/repoquery”, line 700, in returnPkgList  
ygh = self.doPackageLists(what, \*\*kwargs)  
File “/usr/lib/python2.6/site-packages/yum/ **init**.py”, line 2396, in doPackageLists  
ignore\_case=ic)  
File “/usr/lib/python2.6/site-packages/yum/rpmsack.py”, line 622, in returnPackages  
rpats = self.\_compile\_patterns(patterns, ignore\_case)  
File “/usr/lib/python2.6/site-packages/yum/rpmsack.py”, line 549, in \_compile\_patterns  
ret.append((qpat, re.compile(fnmatch.translate(pat))))  
File “/usr/lib64/python2.6/re.py”, line 190, in compile  
return \_compile(pattern, flags)  
File “/usr/lib64/python2.6/re.py”, line 245, in \_compile  
raise error, v # invalid expression  
sre\_constants.error: bad character range

FATAL: all hosts have already failed – aborting

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 13, 2013, 5:54pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/2 "2013-12-13T17:54:01Z")

</div>

So yum isn’t liking some of the output of the previous step and is choking on it.

Do this:

- debug: var=fusionIORPM

Though really I think you’re using yum a bit non-natively.

It would be better to run createrepo and make a repository, configure the repository and then you can just say you want fusionIO installed versus needing to specify a version. (or even that you want the latest)

This way you can also avoid compiling on each individual box – yum mirrors are really easy to set up and just require HTTP.

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 13, 2013, 6:32pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/3 "2013-12-13T18:32:10Z")

</div>

Where would I put that, in the .yml ?

Also…I understand your point, but as far as “natively”…the documentation says that it supports installing from a local RPM. Also, I need to build the RPM manually on the box due to the fact that they (fusionIO) do not offer a pre-built RPM version for the kernel version that I am currently running.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [December 13, 2013, 6:36pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/4 "2013-12-13T18:36:56Z")

</div>

Yep between the two tasks that are there.

– Michael

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 13, 2013, 6:39pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/5 "2013-12-13T18:39:28Z")

</div>

Also worth noting:

changed: [server1] =\> {“changed”: true, “cmd”: "ls /root/rpmbuild/RPMS/x86\_64/iomemory-vsl-$(uname -r)\*.rpm ", “delta”: “0:00:00.005180”, “end”: “2013-12-13 13:38:28.657420”, “item”: “”, “rc”: 0, “start”: “2013-12-13 13:38:28.652240”, “stderr”: “”, “stdout”: “/root/rpmbuild/RPMS/x86\_64/iomemory-vsl-2.6.32-431.el6.x86\_64-2.3.11.183-1.0.el6.x86\_64.rpm”}

so it seems the value is being populated properly.

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 13, 2013, 6:55pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/6 "2013-12-13T18:55:17Z")

</div>

Another thing worth noting (sorry for the multiple posts)

REMOTE\_MODULE yum name=[u’/root/rpmbuild/RPMS/x86\_64/iomemory-vsl-2.6.32-431.el6.x86\_64-2.3.11.183-1.0.el6.x86\_64.rpm’] state=present

so it seems OK?

Not sure where that “u” comes from in the beginning tho…

---

<div class="post-metadata">

**Author:** ![Dimon](https://avatars.discourse-cdn.com/v4/letter/d/eb8c5e/32.png) [@Dimon](https://forum.ansible.com/u/Dimon)\
**Post date:** [December 13, 2013, 8:38pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/7 "2013-12-13T20:38:10Z")

</div>

> Also…I understand your point, but as far as “natively”…the documentation says that it supports installing from a local RPM. Also, I need to build the RPM manually on the box due to the fact that they (fusionIO) do not offer a pre-built RPM version for the kernel version that I am currently running.

sorry about the sideway comment: but you could build RPM on any box with that kernel (and make it explicitely depend on that kernel) and distribute it via Yum like Michael suggested. Are you running custom kernel (non-RPM’ed)? you can still make a dependancy on /boot/vmlinuz-X.Y.Z-foo image if that’s your fancy.

---

<div class="post-metadata">

**Author:** ![Dag\_Wieers](https://avatars.discourse-cdn.com/v4/letter/d/45deac/32.png) [@Dag\_Wieers](https://forum.ansible.com/u/Dag_Wieers)\
**Post date:** [December 13, 2013, 9:28pm UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/8 "2013-12-13T21:28:55Z")

</div>

> Another thing worth noting (sorry for the multiple posts)
> 
> \<server1\> REMOTE\_MODULE yum  
> name=[u'/root/rpmbuild/RPMS/x86\_64/iomemory-vsl-2.6.32-431.el6.x86\_64-2.3.11.183-1.0.el6.x86\_64.rpm']  
> state=present
> 
> so it seems OK?

It does not seem OK. You provide a list as the package-name, not a string. So instead of using fusionIORPM.stdout\_lines, you should use fusionIORPM.stdout, but be sure the ouput only contains a single file !

> Not sure where that "u" comes from in the beginning tho....

The "u" indicates it is a unicode string. Doesn't matter here.

---

<div class="post-metadata">

**Author:** ![BrianAI](https://avatars.discourse-cdn.com/v4/letter/b/cab0a1/32.png) [@BrianAI](https://forum.ansible.com/u/BrianAI)\
**Post date:** [December 14, 2013, 3:59am UTC](https://forum.ansible.com/t/yum-local-install-variable/14152/9 "2013-12-14T03:59:45Z")

</div>

Thanks for the advice.

1. using .stdout instead of .stdout.lines worked just fine with regards to the actual command listed above. Thanks!! 🙂

2. yes, I could build it out and throw it up on a repo (we even have a local repo at our location), but this gives me the ability to continually run this playbook against the server no matter what the kernel version

3. thanks for the info about the “u” 🙂

Thank you again for everyones help in this issue! 🙂
