Thank you! Yes, I know what it is and I actually use something similar.
But one inconvenience is still here for me: when I write 'hosts: all' 
inside a playbook or set variables inside 'group_vars/all', I only want to 
touch the hosts of a standalone environment ('production' or 'staging'). Of 
course I can 'invent' my own group that would only contain hosts I want it 
to, but then this would interfere with the variables overriding mechanism 
(the group 'all' is a special kind of group and I want it to stay like 
that).


On Tuesday, 19 April 2016 23:46:23 UTC+4, J Hawkesworth wrote:
>
> I suggest you have a look at dynamic inventory.
>
> You can mix dynamic inventory with static groups and even use multiple 
> inventory files by using inventory directories - see 
> http://docs.ansible.com/ansible/intro_dynamic_inventory.html#using-inventory-directories-and-multiple-inventory-sources
>
> Hope this helps,
>
> Jon
>
> On Tuesday, April 19, 2016 at 7:28:30 PM UTC+1, Yuri Lukyanov wrote:
>>
>> Hi,
>>
>> Here is what I'm trying to achieve.
>> There are several environments (or clusters) that are relatively 
>> independent but still have some connections in between. Let's say I have 
>> 'production', 'staging' and 'general' environments.
>> The last one contains common machines that are supplementary for the 
>> first two, say, DNS servers. When I create a box in 'production' or 
>> 'staging' I want to add a DNS record for that box on the DNS server inside 
>> 'general' environment.
>>
>> Each environment is described by a standalone inventory file:
>> env/general/inventory
>> env/production/inventory
>> env/staging/inventory
>>
>> My current approach is that all three inventories contain DNS servers. 
>> The 'general' environment has them as they need to be provisioned 
>> initially. 'Production' and 'staging' environments include them because the 
>> environments need to know the DNS servers in order to work with them (I use 
>> 'delegate_to:' to connect to a DNS server to add a record).
>>
>> I would like to avoid having DNS servers in all the inventory files (the 
>> group 'all' should preferably refer to the hosts of an environment). I 
>> would also avoid having a single inventory for all the environments as it 
>> complicates the setup. One approach would be to treat the DNS servers as 
>> external resources for 'production' and 'staging' and to have them set up 
>> as inventory variables. But the provisioning playbook would need to ssh to 
>> a DNS server to add a record and, therefore, may need some additional 
>> arguments like ansible_ssh_host or ansible_ssh_user to connect to it. But 
>> how do I set up those if I don't have the DNS server in the inventory? In 
>> no way...
>>
>> I'd like to point out that the issue is not only about DNS servers. In 
>> the 'general' environment there can be other boxes, for example, a build 
>> machine that is used by both 'production' and 'staging' environments, or a 
>> common monitoring server.
>>
>> So the question is how do you guys deal with similar situations? Does my 
>> setup make sense at all? Maybe I'm doing something very strange?
>>
>>
>>

-- 
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/b70d5a5e-3489-4ea6-a4ab-74db61a3dcff%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to