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/19f2169f-3d76-46c9-b99b-1a30314249ac%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to