I have environments that contain different nodes of different roles/types like: databases, webservers, load-balancers.
Sometimes I need to call every server of the same role/type, but sometimes I need to address an environment.
So sometimes I need to run some update on all ‘webservers’, but sometimes I want to stop and reconfigure all servers in ‘test2’.
At last I need to address a specific environment and do things on different nodes iin sequence, e.g.
ping the ‘database’ inside
‘df -h’ all the webservers
then ‘free -m’ all the load-balancers
How could I tell that the following playbook is only for ‘test1’ environment and I need to run the ‘databases’ part of the playbook only for the databases inside that environment?
What are the starting points or steps? Topics I should read?
We then invoke ansible with “-i test1” or “-i test2” depending on what environment is being targeted. The ability to hit -all- webservers with one command is lost, but you usually don’t want to do that and it’s safer to update test1 before test2 (or production).
You don't loose anything if you put both inventories in the same
directory, then you can call that directory as a 'global unified
inventory' with -i /dir/with/test1andtest2 and still address all
webservers.
So if, instead of having top-level files called “env1”, “env2” and “env3”, we created a “inv” folder and moved them all into there…
You’re saying we could run on just env1 with “-i inv/env1” or all envs with “-i inv”?
Will it still pull in the values from group_vars/env1 when we do the former?