Yum module using nested variables

23 views
Skip to first unread message

Arie Bregman

unread,
Jun 24, 2015, 3:37:56 PM6/24/15
to ansible...@googlegroups.com
Hi everyone,

I have this task:

--------------------------------------------
- name: install test rpms
  sudo: yes
  yum: pkg={{ item }} state=latest
  with_items: common_rpms_deps
--------------------------------------------

and the following yml:

--------------------------------------------
unittest:
  rpm_deps: [
  python-cliff, python-requests-mock, python-webtest
]

common_rpm_deps: [
  gcc, git, python-devel, python-tox, python-testrepository, python-mock, python-pip
  python-testscenarios, python-oslo, "{{ hostvars[inventory_hostname][tester.name]['rpm_deps'] }}"
]
--------------------------------------------

when running it, I get:
msg: this module requires key=value arguments (['pkg=gcc,git,python-devel,python-tox,python-testrepository,python-mock,python-pip', 'python-testscenarios,python-oslo,python-cliff,python-requests-mock,python-webtest', 'state=latest'])

Tried many things, but cant seem to resolve it.

Brian Coca

unread,
Jun 26, 2015, 12:22:10 PM6/26/15
to ansible...@googlegroups.com
that won't work as you think, its appending a commas separated string
as an item of the other list, not merging lists, you want something
like this:

common_rpm_deps: "{{[ gcc, git, python-devel, python-tox,
python-testrepository, python-mock, python-pip python-testscenarios,
python-oslo]|union(hostvars[inventory_hostname][tester.name]['rpm_deps'])}}"

you might need to quote the package names



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages