【发布时间】:2020-12-19 06:54:18
【问题描述】:
我正在尝试在我的 converge 步骤和我的分子的 cleanup 步骤之间共享一个变量。由于两个剧本都在同一台主机上运行,我想我可以使用事实将变量缓存为事实。
在converge.yml:
- name: Cache some variable
set_fact:
cacheable: yes
my_fact: "howdy, world"
在cleanup.yml:
- debug:
msg: "{{ my_fact }}"
并在我的顶级ansible.cfg 中指定:
[defaults]
gathering = smart
fact_caching = jsonfile
fact_caching_connection = /tmp/facts_cache
fact_caching_timeout = 7200
我首先运行 molecule converge,然后运行 molecule cleanup 我收到错误:(重新格式化)
TASK [debug] *******************************************************************
fatal: [cluster-toolchain]: FAILED! => {"msg": "The task includes an option
with an undefined variable. The error was: 'my_fact' is undefined
The error appears to be in '{REDACTED}/cleanup.yml': line 5, column 7, but may be
elsewhere in the file depending on the exact syntax problem.
The offending line appears to be:\n\n tasks:\n - debug:\n ^ here\n"}
我有一些猜测,比如 Molecule 可能没有看到我的顶级 ansible.cfg 或其他什么。
无论如何,我希望在这里得到一些帮助。也许有更好的方法来共享分子世界中的变量。
【问题讨论】:
标签: ansible ansible-facts molecule