On Thu, Aug 14, 2014 at 7:42 AM, Michael DeHaan <[email protected]> wrote:

> "You are right about the intersection of groups - it's a shame you cannot
> declare hosts like (excuse any syntax issues - code looks funny on a
> phone):"
>
> Can you elaborate on what you think is missing?  ":children" to define
> child groups is how that part works, so I'm missing the understanding of
> what part you find lacking there.
>
>
I can create a new a group as a union of other groups (groups of groups),
but AFAIK there's no way to create a new group as the intersection of other
groups.

For instance, if I have a group named "atlanta" and a group named
"webservers", there's no way to define a group called "atlanta_webservers"
that refers to the intersection of those two groups. You have to do "hosts:
atlanta:&webservers" in plays.

Intersections would be really useful because I want to tag my EC2 instances
like:

type=webserver
env=production

And then define a "production_webservers" group as the intersection of
these.

Lorin




>
> On Wed, Aug 13, 2014 at 3:12 AM, Dominic Bou-Samra <[email protected]>
> wrote:
>
>> Hi Lorin,
>>
>> Thanks for replying.
>>
>> So the above presentation is exactly the solution we had arrived at in
>> our Ansible spikes. I wish I had seen that 1 week ago :P.
>>
>> You are right about the intersection of groups - it's a shame you cannot
>> declare hosts like (excuse any syntax issues - code looks funny on a phone):
>>
>> [staging]
>> [staging:children]
>> tag_env_staging
>>
>> [transporters]
>> [transporters:children]
>> tag_type_transporter
>>
>> [staging_transporters]
>> [staging_transporters:children]
>> staging
>> transporters
>>
>> And then in your playbook, declare:
>>
>> hosts: staging_transporters
>>
>> But perhaps it's better to pass in variables like:
>>
>> // configure all staging transporters in us-east-1. Staging inventory
>> declares group_var with staging param
>> ansible-playbook -i staging -e zone=us-east-1 transporter.yml
>>
>> With transporter.yml looking like:
>>
>> - name: Config transporters
>>   hosts: {{environment}}:&{{zone}}:&transporters
>>
>> What do you think of that?
>>
>> On Tuesday, August 12, 2014 12:39:26 PM UTC+10, Lorin Hochstein wrote:
>>>
>>> Hi Dominic:
>>>
>>> To support mixing static with dynamic inventory, have the "hostfile"
>>> entry in your ansible.cfg point to a directory instead of a file. For
>>> example, my ansible.cfg contains:
>>>
>>> [defaults]
>>> hostfile = inventory
>>>
>>> And my inventory directory looks like this:
>>>
>>> inventory/hosts
>>> inventory/ec2.py
>>> inventory/ec2.ini
>>>
>>> The inventory/hosts file is a static Ansible inventory file. The
>>> inventory/ec2.py and inventory/ec2.ini are the dynamic inventory parts. You
>>> can edit ec2.ini to specify which regions you want, the example ec2.ini
>>> file that ships with ansible is pretty clear on how to do this.
>>>
>>> I gave a talk on this topic a few months back, the slides may not mean
>>> too much without me talking (they're pretty sparse) but here they are:
>>> http://go-talks.appspot.com/github.com/lorin/camp-devops-talk/talk.slide
>>>
>>> You can provision instances using the ec2 module. I recommend that you
>>> use tags when you do provisioning because ec2.py will automatically create
>>> groups based on tags. One gotcha here is that ec2.py will cache by default,
>>> so if you want to launch an instance and then configure it immediately
>>> after it comes up, you'll need to disable caching before in ec2.ini (set
>>> cache_max_age=0).
>>>
>>> If you want to do "Australian transporters in production", I don't think
>>> you can actually define a new group as an intersection of groups, so you'd
>>> have to specify the hosts by explicitly doing the intersection of groups:
>>>
>>> hosts: australia:&transports:&production
>>>
>>> (where "australia", "transports" and "production" are all groups that I
>>> have assumed you have created via tags).
>>>
>>>
>>>
>>> On Monday, August 11, 2014 3:21:47 AM UTC-4, Dominic Bou-Samra wrote:
>>>>
>>>> Hi all,
>>>>
>>>> I've been playing with Ansible as a solution to our deployment
>>>> infrastructure. Our stack is:
>>>>
>>>>    - Dozens of "transporters" running on EC2.
>>>>    - Dozens of "detectors" running on EC2
>>>>    - Production and staging environments
>>>>    - Multiple regions (atm US East and Sydney)
>>>>
>>>> What I require from Ansible is:
>>>>
>>>>    - A dynamic inventory, MIXED IN with a static group declaration. I
>>>>    would like to be able to refer to my "Australian transporters in
>>>>    production", as easily as possible. I would like no IP's/hostnames 
>>>> stored
>>>>    locally (i.e, use EC2.py as a dynamic inventory).
>>>>    - Ability to provision new EC2 instances in any region, in any
>>>>    environment.
>>>>    - As little duplication as possible.
>>>>
>>>> I am struggling with trying to lay my project out so that I can achieve
>>>> these goals.
>>>>
>>>>
>>>> Could anyone provide me with some suggestions or example layouts,
>>>> ideally with sample command? Let me know if you need more information and
>>>> what I have so far
>>>>
>>>  --
>> 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/fb2e7d05-0664-445a-81a9-64c6b2a8ab0e%40googlegroups.com
>> <https://groups.google.com/d/msgid/ansible-project/fb2e7d05-0664-445a-81a9-64c6b2a8ab0e%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 a topic in the
> Google Groups "Ansible Project" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/ansible-project/Ohx3KEYwZdw/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/CA%2BnsWgym88h0GsehetMbygfPGwzvKJTkgmNs0fabhmCdgN%2BD8w%40mail.gmail.com
> <https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgym88h0GsehetMbygfPGwzvKJTkgmNs0fabhmCdgN%2BD8w%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/CACkJihNU1xdY75QXkub2yVBR19XsWy7zXJBsbzhu4uWu1GMH4A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to