【发布时间】:2019-10-28 01:34:33
【问题描述】:
我为 ansible 定义了一个 yml 变量文件,结构如下:
appserver:
root_directory: C:\app
config_directory: '{{ root_directory }}\config'
似乎无法正确解释第二个变量config_directory,我得到了VARIABLE NOT FOUND ERROR。
我试过了:
appserver:
root_directory: C:\app
config_directory: '{{ appserver.root_directory }}\config'
它也不起作用,我有很长的错误痕迹,最有趣的部分是:
recursive loop detected in template string:{{ appserver.root_directory }}\config
当我使用双引号而不是单引号时,
应用服务器: 根目录:C:\app config_directory: "{{ appserver.root_directory }}\config"
我收到以下错误:
The offending line appears to be:
app_root: D:\WynsureEnvironments\Application
wynsure_root: "{{ appserver.root_directory }}\config"
^ here
We could be wrong, but this one looks like it might be an issue with
missing quotes. Always quote template expression brackets when they
start a value. For instance:
with_items:
- {{ foo }}
应该写成:
with_items:
- "{{ foo }}"
在使用变量块时,如何重复使用变量来分配新变量?
谢谢!
【问题讨论】:
标签: ansible yaml ansible-2.x