Uwe Sauter
unread,Aug 14, 2017, 12:26:23 PM8/14/17Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to Ansible Project
Hi,
I'm trying to keep my playbooks and related var files portable. Currently I'm stuck with the following:
### input.yaml ###
---
base: '/exports'
image: '{{ base }}/image'
config: '{{ base }}/config'
################
### playbook ###
---
- hosts: localhost
connection: local
gather_facts: false
tasks:
- include_vars:
file: input.yaml
name: input
- debug: var=input
#################
### output ###
$ ansible-playbook test.yaml
PLAY [localhost] ***************************************************************
TASK [include_vars] ************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"input": "VARIABLE IS NOT DEFINED!"
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
##############
If I change input.yaml to
#######
---
base: '/exports'
image: '/exports/image'
config: '/exports/config'
#######
it gets loaded correctly
#######
$ ansible-playbook test.yaml
PLAY [localhost] ***************************************************************
TASK [include_vars] ************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"input": {
"base": "/exports",
"config": "/exports/config",
"image": "/exports/image"
}
}
PLAY RECAP *********************************************************************
localhost : ok=2 changed=0 unreachable=0 failed=0
#######
but I loose portability.
I read somewhere on the net that Ansible doesn't support variable expansion in include_vars tasks. Any suggestions on
how to achieve what I'm trying to do?
What's the reasoning behind Ansible not doing variable expansion on include_vars?
Regards,
Uwe