I have a playbook
---
- hosts: 127.0.0.1
connection: local
vars:
WORK_DIR: /somefolder
tasks:
- debug:
msg: "{{ WORK_DIR }}"
- lineinfile:
path: /somefolder/some.file
regexp: '"display_name":'
line: ' "display_name": "another_name",'
works fine and I have a debug
ok: [127.0.0.1] => {
"msg": "/somefolder"
}
but when I try to use variable in path like
- hosts: 127.0.0.1
connection: local
vars:
WORK_DIR: /somefolder
tasks:
- debug:
msg: "{{ WORK_DIR }}"
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
regexp: '"display_name":'
line: ' "display_name": "another_name",'
there is an error
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
^ here
The question is why ? Is this a bug or feature or something else ?
Quotes misuse.
You should use path: "{{ WORK_DIR }}/some.file".
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With