You can create dynamic groups by using the group_by module:

- name: Create groups based on location
  group_by: key={{ location }}


then use something to similar to what Brian had said earlier in the play:

ansible-playbook <all your other options> -e 'mylocation=room1'


playbook should contain:

hosts: "{{ mylocation }}"

- James


On Fri, Mar 7, 2014 at 11:29 AM, Francois Legrand <
francois.legr...@gmail.com> wrote:

> Thanks for your answer. I know that I could do another group based on
> location... but the point is that you get very fast a lot of groups... thus
> when you add/remove/update a new computer you have to do it at many places
> in the host file so it's easy to forget to update a group !
>
>
> Le vendredi 7 mars 2014 16:25:16 UTC+1, Brian Coca a écrit :
>
>> in play:
>> hosts: "{{mytarget}}"
>>
>> on command line:
>>
>> -e 'mytarget=myhost:myhost2'
>>
>> though i you could also use --limit 'room1' (and have a room1 group for
>> those hosts) or --limit 'myhost:myhost2'
>>
>  --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/36459bd6-292b-428c-a186-31f4310135e3%40googlegroups.com<https://groups.google.com/d/msgid/ansible-project/36459bd6-292b-428c-a186-31f4310135e3%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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAJvmrNO4L031abTi%3DW2M%2BVEOa7sthS6dvdS8sqX6tWkjKvMJhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to