I currently have been putting both hosts and host related variables into the /etc/ansible/hosts file with variables such as this:
[myhosts]
host1
host2
[host1]
host1.domain
[host1:vars]
var1=“Some data”
var2=“Some other data”
tag1=myTag
[host2]
host2.domain
[host2:vars]
…
etc. This all works but is not overly scalable as the number of servers grows.
How can I break this up into a more directory based structure so that things can scale better with many servers. I’ve tried to read through information on host_vars and group_vars but have not succeeded in getting the syntax set up properly to mimic what I have working with the hosts file.
Can someone help me figure out directory structure, naming, and setup to get that working?
Perhaps I’m inching closer. Can I pick up the target from somewhere else? Or have target in the hosts file in some way that ansible will know to use it instead of having to add it to the command line?