0
我有一個劇本是否有可能在lineinfile可用模塊中使用路徑中的變量?
---
- 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",'
工作正常,我有一個調試
ok: [127.0.0.1] => {
"msg": "/somefolder"
}
,但是當我嘗試使用變量路徑一樣
- 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",'
存在錯誤
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
^here
問題是爲什麼?這是一個錯誤或功能還是別的?