Skip to content

Instantly share code, notes, and snippets.

@eb4x
Last active March 7, 2019 14:03
Show Gist options
  • Save eb4x/d6341e63da54193263b17ba7a65a3d5a to your computer and use it in GitHub Desktop.
Save eb4x/d6341e63da54193263b17ba7a65a3d5a to your computer and use it in GitHub Desktop.
TASK [create inventory/this_is_defined_in_vars]
inventory/this_is_defined_in_vars
[[{'label2': 'muchacho', 'label': 'hola'}]]
---
- 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') }}]"
@eb4x
Copy link
Author

eb4x commented Mar 7, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment