I have a playbook that installs a web application on multiple hosts (one host per customer).
- $environment-$version.yml (because environment configuration can change with each new version)
- 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