There is no case statement in ansible.
You can look into "group_by" when eliminating repeated conditionals if this
works for you.
- hosts: webservers
tasks:
- group_by: key=os-{{ ansible_os_family }}
- hosts:webservers:&os-Debian
tasks:
- ...
etc
On Sat, May 10, 2014 at 10:09 AM, Navid Paya <[email protected]>wrote:
> Hi all
> We have a mix of Debian and Redhat in our infrastructure so basically for
> every single step, I have to add two of the same operators for both of
> them, like this:
>
> - name: Install prerequisite packages
> action: apt pkg={{item}} state=installed
> with_items:
> - sysstat
> when: ansible_os_family == 'Debian'
>
> - name: Install prerequisite packages
> action: yum pkg={{item}} state=installed
> with_items:
> - sysstat
> when: ansible_os_family == 'RedHat'
>
> Does Ansible have an operator similar to the case operator in Ruby or
> Chef<http://docs.opscode.com/chef/dsl_recipe.html#case-statements>and Puppet
> for that matter?
>
> --
> 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/8698728f-b185-4ba2-9b1f-b2bee476bba9%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/8698728f-b185-4ba2-9b1f-b2bee476bba9%40googlegroups.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/CA%2BnsWgyanEgXieR%3DOAAk_CZfM_3eZ4UPBdCEZa%2B_Tytb60_jMw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.