On Thu, 12 Feb 2015 08:59 -0800, Alexey Wasilyev <[email protected]>
wrote:
> Hello, everybody.
>
> Can somebody show me the working example of following code?
>
> - name: 'Install packages'
> action: >
> {{ ansible_pkg_mgr }} name={{ item }} state=installed
> with_items: [package1, package2]
>
> Without with_items - its worked. When I specify yum/apt instead {{
> ansible_pkg_mgr }} - it's worked.
> How I can combine with_items and {{ ansible_pkg_mgr }} together?
Some valid ways to declare this:
- name: install packages
local_action: "{{ ansible_pkg_mgr }} name={{ item }} state=latest"
with_items:
- lsof
- nmap
- name: install packages
local_action: "{{ ansible_pkg_mgr }} name={{ item }} state=latest"
with_items: [ lsof, nmap ]
- name: install packages
local_action: >
{{ ansible_pkg_mgr }} name={{ item }} state=latest
with_items: [ lsof, nmap ]
Generally I try to use YAML only and avoid Ansible's syntax (with equal
signs). However, with free-form arguments, it's hard to avoid it. IMHO,
it's too much flexibility and backward compatibility, but that's because
I don't have a "legacy" code base to worry about.
Giovanni
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/1423790393.1069199.226914481.0C5A232F%40webmail.messagingengine.com.
For more options, visit https://groups.google.com/d/optout.