I am writing a custom Action Plugin for Ansible which I use in my playbook and I am trying to set a variable that will be used in the next task, in the playbook, by a (custom) module.
Effectively, the playbook equivalent of what I am trying to mimic is a set_fact task like so:
- name: set_fact task
set_fact:
ansible_python_interpreter: /path/to/python
In my custom Action Plugin, I have used self._execute_module
before to execute other modules (such as slurp) within the plugin code. However, with the set_fact
module it doesn't seem to be updating the ansible_python_interpreter
variable, as expected.
I have tried the following:
self._execute_module(module_name='ansible.builtin.set_fact',
module_args=dict(ansible_python_interpreter=/path/to/python),
task_vars=task_vars)
And I have also tried different variations of module_args
:
module_args=dict(key_value={ansible_python_interpreter=/path/to/python})
module_args=dict(key_value='ansible_python_interpreter:/path/to/python')
However, my ansible_python_interpreter
does not seem to be changing.
Any help, please?