我试图在我的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
或其他什么。
无论如何,我希望在这里得到一些帮助。也许有更好的方法来分享分子世界中的变量。