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
--
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/62740c32-23b0-3e56-342d-2d8ae7ddb424%40gmail.com.
For more options, visit https://groups.google.com/d/optout.