Hello Kai,
Thanks for your answer. But the method you mentioned don't work for me. I
created the following plays:
---
- hosts: all
- name: group by OS
group_by: key=os_{{ [ansible_distribution] }}
changed_when: False
- hosts: os_RedHat
roles:
- common
But when I try to run this playbook I got an error:
ansible-playbook -i staging site.yml -C
ERROR! 'group_by' is not a valid attribute for a Play
The error appears to have been in '/root/ansible/set_baseline.yml': line 2,
column 3, but may
be elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:
---
- name: group by OS
^ here
At first I thought my problem could be using the "- hosts" option two times
in one playbook. But I got the same error without the first "- hosts"
option in the file. What am I doing wrong?
Thanks in advance for you help.
Kind regards,
Joerg
Am Montag, 25. Juli 2016 13:20:08 UTC+2 schrieb Jörg Kastning:
>
> Dear all,
>
> I'd like to map a role to a group of hosts with a specific operating
> system.
>
> So far I read Applying ‘when’ to roles and includes
> <http://docs.ansible.com/ansible/playbooks_conditionals.html#applying-when-to-roles-and-includes>
>
> and the module description of group_by
> <http://docs.ansible.com/ansible/group_by_module.html>. But I could not
> figure out how to use group_by to use a specific role only in cases where a
> variable matches an operating system. Could someone give an example, please?
>
> Do I have to set some group_var first to use with group_by?
>
> Kind regards,
> Joerg
>
--
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/b5724d80-1811-4f79-8773-a69c1b74ff15%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.