I am having trouble wrapping my head around how i should setup my variable 
structure. I have two locations with multiple environments at each. I can 
have different variables depending on the location and production env.

For example, I have a dev web server at location A and a prod web server at 
location B. I want them to each have a separate virtual host. What is the 
best way to accomplish this?

I tried putting variables in the group_vars directory with a separate 
directory for each location, then subdirectories for each environment, but 
then I each location is going to pull in every variable from all 
environments.

I tried just using group_vars (all, webserver, etc) but I couldn't get this 
to work either unless I have a group_var file for every group at every 
location for each environment.

The only other thing that I can think of to do to accomplish this is to put 
the defaults for all groups in group_vars. In my inventory file for each 
location or environment I can assign a group_var (i.e. env_type=dev). Then 
in my playbook I can do:

var_files:
 -  /var/{{  location  }}/{{  env_type  }}/group_name.yml

I want to avoid duplicating variables that are the same for each env and 
make the roles as dynamic as possible. I've read through the docs and can't 
seem to make sense of it. I am sure that Ansible or someone else has 
figured out. I just cant find it. If someone can point me in the right 
direction I would really appreciate it.

Thanks.

-- 
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/81193fa5-f569-4146-87e9-d3e89022acd3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to