我有一本剧本
---
- 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",'
Run Code Online (Sandbox Code Playgroud)
工作正常,我有一个调试
ok: [127.0.0.1] => {
"msg": "/somefolder"
}
Run Code Online (Sandbox Code Playgroud)
但是当我尝试在路径中使用变量时
- 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",'
Run Code Online (Sandbox Code Playgroud)
有错误
- lineinfile:
path: "{{ WORK_DIR }}"/some.file
^ here
Run Code Online (Sandbox Code Playgroud)
问题是为什么?这是错误或功能还是其他什么?
| 归档时间: |
|
| 查看次数: |
8420 次 |
| 最近记录: |