Hello - Can include_vars also include predefined variables? I have a variable {{ WMS_HOME }} which debug resoles properly but include_vars doesn’t carry it through.
role/vars/SDN500.yml
backup_files:
- src_path: “{{ WMS_HOME }}/distribution/”
filename: “scope.war”
dest_path: “{{ SDN_backup_dir }}/{{ code_tier }}/{{ inventory_hostname_short }}/scope/”
Code:
`
-
name: Include vars for SDN list
tags: sdnlist
include_vars: “{{ item }}.yml”
register: include_vars_output
with_items: “{{ SDNs }}” -
debug: msg=“Home={{ WMOS_HOME }}”
tags: sdnlist -
debug: msg=“Src Path={{ item.src_path }}”
tags: sdnlist
with_items: “{{ backup_files }}”
`
Output:
TASK [role_utility_sdn_backups : Include vars for SDN list] ********************
ok: [host] => (item=SDN500)
TASK [role_utility_sdn_backups : debug] ****************************************
ok: [host] => {
“msg”: “Home=/apps/scope/manh/WM”
}
TASK [role_utility_sdn_backups : debug] ****************************************
ok: [host] => (item={u’filename’: u’scope.war’, u’src_path’: u’{# WMS_HOME #}/distribution/‘, u’dest_path’: u’{# SDN_backup_dir #}/{# code_tier #}/{# inventory_hostname_short #}/scope/'}) => {
“item”: {
“dest_path”: “{# SDN_backup_dir #}/{# code_tier #}/{# inventory_hostname_short #}/scope/”,
“filename”: “scope.war”,
“src_path”: “{# WMS_HOME #}/distribution/”
},
“msg”: “Src Path=/distribution/”
}
Thanks