I was trying to avoid a group_var file for everything but it looks like
that is the route that I am going to have to go. I have set the
parent-child relationship of the groups in my inventory files. So in my
group_vars directory I have location_a, location_b, dev, prod, qa,
location_a_dev, location_b_dev, location_a_web, location_b_web, etc. This
accomplishes what I want but I feel like it is going to get out of control
very quickly. If there is a better way to accomplish this please let me
know.
On Thursday, April 2, 2015 at 10:43:43 PM UTC-4, Johnathan Komara wrote:
>
> 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/ca42704a-3a87-405e-a906-1cf3a4da7b88%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.