我正在为Anable编写一个定制的操作插件,我在我的 playbook 中使用它,我正在try 设置一个变量,该变量将在下一个任务中使用,在 playbook 中,通过(自定义)模块.
实际上,与我试图模仿的 playbook 等同的是一个设置事实的任务,如下所示:
- name: set_fact task
set_fact:
ansible_python_interpreter: /path/to/python
在我的定制操作插件中,我以前使用过self._execute_module
来执行插件代码中的其他模块(比如slurp).然而,对于set_fact
模块,它似乎没有像预期的那样更新ansible_python_interpreter
变量.
我try 了以下几种方法:
self._execute_module(module_name='ansible.builtin.set_fact',
module_args=dict(ansible_python_interpreter=/path/to/python),
task_vars=task_vars)
我还try 了module_args
的不同版本:
module_args=dict(key_value={ansible_python_interpreter=/path/to/python})
module_args=dict(key_value='ansible_python_interpreter:/path/to/python')
然而,我的ansible_python_interpreter
似乎并没有改变.
有什么需要帮忙的吗?