Can someone give me a more complete example of how to tie together ansible hosts file and the hosts_var directory?
My ansible hosts file is getting out of hand and I want to break it up better. I use variables for various pieces of info. Currently my hosts file has sections like this:
[myserver]
myserver.my.domain
[myserver:vars]
host=myserver.my.domain
tagName=myserver
tagOwner=thanstra
tagBackup=True
And then I can later use the variables which are set there:
- name: Tag the instance Name
command: aws ec2 create-tags --resources {{ ansible_ec2_instance_id }} --tags Key=Name,Value={{ tagName }}
I’d like to break this up to build files in hosts_var with those various vars in separate files for each server. But I’m having trouble figuring out the right syntax, naming conventions, etc for what needs to go in ansible hosts file and host_vars/[connected file].
Can someone give me clear information on what files I need and what the syntax of the files should look like?
Thank you!