The information you are looking for in nicely documented in the Ansible 
docs - http://docs.ansible.com/ansible/intro_inventory.html

You need to create forlders named exactly as 'group_vars' and 'host_vars' 
right beside your host file and in them you create files with the same name 
as your group or host (optionaly with a .yaml extension).

On Thursday, 31 March 2016 21:51:39 UTC+5:30, thanstra wrote:
>
> 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!
>

-- 
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/2807e449-463e-4171-af6b-e9d31236832a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to