Ah, sorry. My mistake.

Here is my current playbook, which works as designed:
---
- hosts: all

  tasks:
    - name: Group by OS
      group_by: key=os_{{ ansible_distribution }}
      changed_when: False

- hosts: os_RedHat
  roles:
    - common

Regards,
Joerg

Am Dienstag, 2. August 2016 14:05:49 UTC+2 schrieb Jörg Kastning:
>
> 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/9a2b8362-d27b-42af-b734-da50e3931433%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to