Hi everyone,

I have a playbook that installs a web application on multiple hosts (one 
host per customer).

The following variable hierarchy would be perfect for my environment:

- common.yml
- $environment
- $environment-$version.yml (because environment configuration can change 
with each new version)
- fqdn.yml

In my playbook I have solved this via host_vars, group_vars and 
include_vars:

./group_vars
./group_vars/devel.yml
./group_vars/test.yml
./group_vars/production.yml

./host_vars
./host_vars/customer1.yml
./host_vars/customer2.yml
./host_vars/customer3.yml

- fail:
    msg: "app_version is not defined (application not yet deployed?)."
  when: app_version is not defined

- name: Include common vars
  include_vars:
    file: "common.yml"

- name: Include system type specific vars
  include_vars:
    file: "{{ app_version }}/{{ app_environment }}.yml"


- name: HACK? HACK? HACK? Include hostname specific vars
  include_vars:
    file: "host_vars/{{ inventory_hostname }}.yml"


Because variables included with include_vars have a higher priority then 
group_vars and host_vars, I need to include them again, but It feels hacky.

Does anyone have any opinions on that or any suggestions?


My desired solution would be to add hosts to more specific groups. 

But I cannot configure this in the inventory, because the version to deploy is 
determined by a fact on the remote host.


./group_vars

./group_vars/devel.yml

./group_vars/devel-1.yml

./group_vars/devel-2.yml

./group_vars/test.yml

./group_vars/test-1.yml

./group_vars/test-2.yml

./group_vars/production.yml

./group_vars/production-1.yml

./group_vars/production-2.yml

I had a look at add_host, which first seemed to exactly what I need, but having 
a closer look it does not work for me.


So I will either have to live with that solution, or someone has a better idea.


Regards

Daniel

-- 
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/100c907c-4378-46c3-a4f3-a05a3cf566d9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to