Hey,
i am working on a infrastructure that is completely managed by ansible (great tool btw). we are currently in the process of adding different environments (production, prelive ...) and we hit a problem that i need help with to understand whats going wrong here.
we have a group_vars file "all" which contains most of the configuration and then each role / environment overrides any needed variables via it's hostfile or a custom yml provided via -e on the command line.
group_vars/all:
search_domains:
custom.yml (which is loaded via -e on the command line)
search_domains:
As far is understand variable precedence the custom.yml values are overriding the values from all. this is somewhat wokring as intended.
Now come the thing i don't seem to understand. Given this playbook:
---
- name: Installs or updates servers
hosts: search
roles:
- common
- search
sudo: yes
tasks:
- include: roles/common/tasks/apache/add-vhost.yml
vars:
domains: "{{search_domains}}"
I would expect that inside app-vhost.yml the variable domains has the contents of custom.yml. but it doesn't. to get a clearer picture on whats going on i added those debug statements to the add-vhosts.yml
- debug: var= search_domains
- debug: var=domains
And guess what... the first debug show the correct content from custom.yml and the second one the contents from the group_vars/all.
I expected that the vars from the include will override anything in the scope of the included file. It seems that this is not the case. Can someone giveme some pointers on how to solve this?
cheers
Chris