# action plugin: modify task\_vars?

**URL:** <https://forum.ansible.com/t/action-plugin-modify-task-vars/33304>\
**Category:** Ansible Project\
**Created:** [July 2, 2020, 11:33am UTC](https://forum.ansible.com/t/action-plugin-modify-task-vars/33304 "2020-07-02T11:33:47Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Gregory\_Christy](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Christy](https://forum.ansible.com/u/Gregory_Christy)\
**Post date:** [July 2, 2020, 11:33am UTC](https://forum.ansible.com/t/action-plugin-modify-task-vars/33304/1 "2020-07-02T11:33:47Z")

</div>

Hello everybody,

I have a custom module and would like to set the ansible\_python\_interpreter variable from within a corresponding action plugin.  
This is what I do in the action plugin:

`task_vars_modified = task_vars.copy() task_vars_modified['ansible_python_interpreter'] = '<path/to/my/python>' result = merge_hash(result, self._execute_module(module_args=module_args, task_vars=task_vars_modified))`

Unfortunately this has no effect. Using the playbook debugger I can verify that ansible\_python\_interpreter is not set for the module.  
I am sure that the action plugin is called.  
What am I doing wrong?  
Is it possible at all to modify task\_vars? I cannot find an example for this approach.

Background:  
My custom module makes use of some python modules. I do not want to install these modules globally so I’m using a virtual environment.  
Obviously now the ansible module needs to use the python binary within the virtual environment.  
I would like to encapsulate this so that the user does not have to remember to set ansible\_python\_interpreter each time he uses the module.

Thanks and Regards,  
Carsten

---

<div class="post-metadata">

**Author:** ![Gregory\_Christy](https://avatars.discourse-cdn.com/v4/letter/g/ecccb3/32.png) [@Gregory\_Christy](https://forum.ansible.com/u/Gregory_Christy)\
**Post date:** [July 6, 2020, 8:14am UTC](https://forum.ansible.com/t/action-plugin-modify-task-vars/33304/2 "2020-07-06T08:14:05Z")

</div>

I’ve reposted this question here: [https://groups.google.com/forum/#!topic/ansible-devel/Lyz0cCvmJvc](https://groups.google.com/forum/#!topic/ansible-devel/Lyz0cCvmJvc)
