Last active
March 7, 2019 14:03
-
-
Save eb4x/d6341e63da54193263b17ba7a65a3d5a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TASK [create inventory/this_is_defined_in_vars] | |
inventory/this_is_defined_in_vars | |
[[{'label2': 'muchacho', 'label': 'hola'}]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: test lineinfile | |
hosts: localhost | |
gather_facts: false | |
vars: | |
this_is_defined_in_vars: | |
- label: hola | |
label2: muchacho | |
tasks: | |
- name: create inventory/ | |
file: | |
path: inventory/ | |
state: directory | |
- name: create inventory/{{ thisvarisundefined | default('this_is_defined_in_vars') }} | |
lineinfile: | |
path: "inventory/{{ thisvarisundefined | default('this_is_defined_in_vars') }}" | |
create: true | |
line: "[{{ thisvarisundefined | default('this_is_defined_in_vars') }}]" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How come the lineinfile "line" expands "default('this_is_defined_in_vars') ? While "path" and "name" treat default('this_is_defined_in_vars') as strings.