Hi Anand
Are you sure your indenting is correct? Here’s an example from one of my
role task files, known working with Ansible v1.8.2 (packages trimmed for
brevity)
---
- name: Install packages (apt)
apt:
pkg:
- bash-completion
- bind9utils
- vim-nox
- zsh
state: present
when: ansible_os_family == 'Debian'
- name: Install packages (yum)
yum:
name:
- bind-utils
- byobu
- vim-enhanced
- zsh
state: present
when: ansible_os_family == 'RedHat'
On 2 February 2015 at 12:34, Anand Buddhdev <[email protected]> wrote:
> Hi Giovanni,
>
> Your suggestion works. But I think what I was trying to say is that
> Ansible's playbook syntax is mixed. Wouldn't it be cool if it were pure
> YAML, with Jinja templating? Then it would allow something like:
>
> - hosts: myhost
> tasks:
> - name: install packages
> yum:
> name:
> - tmux
> - screen
> {% if ansible_distribution_major_version == '6' %}
> - lsof
> {% endif %}
>
> Instead of inventing ansible-specific loops, we could just use the power
> of Jinja templating.
>
> On 2 February 2015 at 11:10, Giovanni Tirloni <[email protected]> wrote:
>
>> On Mon, 02 Feb 2015 10:58 +0100, Anand Buddhdev <[email protected]>
>> wrote:
>> > Hi Tom,
>> >
>> > I just tried the syntax you suggested.
>> >
>> > My very simple playbook is:
>> >
>> > - hosts: myhost
>> > tasks:
>> > - name: install packages
>> > yum:
>> > name:
>> > - screen
>> > - tmux
>> > state: installed
>> >
>>
>> - hosts: myhost
>> tasks:
>> - name: install packages
>> yum:
>> name: "{{ item }}"
>> state: latest
>> with_items:
>> - screen
>> - tmux
>>
>>
>> Useful reading:
>> http://docs.ansible.com/playbooks_loops.html
>>
>> Giovanni
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Ansible Project" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/ansible-project/dGJRlrohfmY/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, 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/1422871831.2610733.221884249.32774E87%40webmail.messagingengine.com
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
> --
> 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/CANbPJFn3ZbnsGfm05q1ZqCYPtpOQGyzPL9qTumhgOGhgcezZHw%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CANbPJFn3ZbnsGfm05q1ZqCYPtpOQGyzPL9qTumhgOGhgcezZHw%40mail.gmail.com?utm_medium=email&utm_source=footer>
> .
>
> For more options, visit https://groups.google.com/d/optout.
>
--
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/CAAnNz0N8%2B7hF3fuOJ7zXgFpSQ0j%3DjP5aH4hR8nLmMM%3D%3DXxg_Zw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.