When doing a task like this in order to install local packages (a la yum localinstall):
- name: Install local packages
yum:
name="/my/path/{{ item }}"
state=installed
with_items: list_of_packages
Where list_of_packages is defined in vars/main.yml as:
---
list_of_packages:
- package1.rpm
- package2.rpm
...
Yum tries to be smart and put all items in one command but ends only adding the path to the first package:
REMOTE_MODULE yum name="/my/path/package1.rpm,package2.rpm" state=installed
And obviously fails not finding the second package
I've tried adding the path inside like: {{ "/my/path/"+item }}
and keeps doing the same.
Is there a way besides duplicating "list_of_packages" with the base path added? (workaround i'm using)
EDIT: Detailed test playbook (ansible version 1.9.2):
# cat playbooks/testlocalinstall.yml
---
- hosts: all:!localhost
vars:
list_of_packages:
- oracleasmlib-2.0.4-1.el6.x86_64.rpm
- oracleasm-support-2.1.8-1.el6.x86_64.rpm
tasks:
- name: Install Packages
yum: name=/software/{{ item }} state=installed
with_items: list_of_packages
Result:
# ansible-playbook playbooks/testlocalinstall.yml -i inventory/myinv -vvv
PLAY [all:!localhost] *********************************************************
GATHERING FACTS ***************************************************************
<testmachine> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO testmachine
<testmachine> REMOTE_MODULE setup
<testmachine> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1441783338.15-74757921814888 && echo $HOME/.ansible/tmp/ansible-tmp-1441783338.15-74757921814888'
<testmachine> PUT /tmp/tmp_955vP TO /root/.ansible/tmp/ansible-tmp-1441783338.15-74757921814888/setup
<testmachine> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python /root/.ansible/tmp/ansible-tmp-1441783338.15-74757921814888/setup; rm -rf /root/.ansible/tmp/ansible-tmp-1441783338.15-74757921814888/ >/dev/null 2>&1'
ok: [testmachine]
TASK: [Install Packages] ******************************************************
<testmachine> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO testmachine
<testmachine> REMOTE_MODULE yum name=/software/oracleasmlib-2.0.4-1.el6.x86_64.rpm,oracleasm-support-2.1.8-1.el6.x86_64.rpm state=installed
<testmachine> EXEC /bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1441783339.35-66981904309720 && echo $HOME/.ansible/tmp/ansible-tmp-1441783339.35-66981904309720'
<testmachine> PUT /tmp/tmpF0hiqP TO /root/.ansible/tmp/ansible-tmp-1441783339.35-66981904309720/yum
<testmachine> EXEC /bin/sh -c 'LANG=en_US.UTF-8 LC_CTYPE=en_US.UTF-8 /usr/bin/python -tt /root/.ansible/tmp/ansible-tmp-1441783339.35-66981904309720/yum; rm -rf /root/.ansible/tmp/ansible-tmp-1441783339.35-66981904309720/ >/dev/null 2>&1'
failed: [testmachine] => (item=oracleasmlib-2.0.4-1.el6.x86_64.rpm,oracleasm-support-2.1.8-1.el6.x86_64.rpm) => {"changed": false, "failed": true, "item": "oracleasmlib-2.0.4-1.el6.x86_64.rpm,oracleasm-support-2.1.8-1.el6.x86_64.rpm", "rc": 0, "results": []}
msg: No Package file matching 'oracleasm-support-2.1.8-1.el6.x86_64.rpm' found on system
msg:
No Package file matching 'oracleasm-support-2.1.8-1.el6.x86_64.rpm' found on system
FATAL: all hosts have already failed -- aborting
PLAY RECAP ********************************************************************
to retry, use: --limit @/root/testlocalinstall.retry
testmachine : ok=1 changed=0 unreachable=0 failed=1
Adding the path to each package on the list works fine
Thanks.