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_domain: search.example.com
search_domains:
  - { domain : 'search.example.com', aliases : [] } 

custom.yml (which is loaded via -e on the command line)

search_domain: prelive.search.example.com
search_domains:
  - { domain : 'prelive.search.example.com', aliases : [] } 


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

-- 
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/0514d071-7e63-4d93-a17b-9215914c7030%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to