# How to capture module\_args in a variable

**URL:** <https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137>\
**Category:** Ansible Project\
**Created:** [November 2, 2020, 8:16am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137 "2020-11-02T08:16:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Shreya\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Shreya\_Bhardwaj](https://forum.ansible.com/u/Shreya_Bhardwaj)\
**Post date:** [November 2, 2020, 8:16am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/1 "2020-11-02T08:16:20Z")

</div>

Hello everyone,

I wanted to capture the data present in the module\_args.  
But when I register the output in a variable, I don’t get the invocation{module\_args} part in it.

The way we access ansible facts: {ansible facts[‘whatever you want to know’][‘xyz’]}

Is there a way to access the module\_args in the playbook or use them in conditionals somehow?

Thanks!

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [November 2, 2020, 8:25am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/2 "2020-11-02T08:25:23Z")

</div>

module\_args accepts user input. That means those are already with the user. I am not sure how that will be useful. Can you provide a use case?

---

<div class="post-metadata">

**Author:** ![Shreya\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Shreya\_Bhardwaj](https://forum.ansible.com/u/Shreya_Bhardwaj)\
**Post date:** [November 3, 2020, 7:26am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/3 "2020-11-03T07:26:55Z")

</div>

Sure.

When I run a playbook, the output I get on the shell includes something like:

“ansible\_facts”: {  
“discovered\_interpreter\_python”: “/usr/bin/python”  
},  
“changed”: false,  
“invocation”: {  
“module\_args”: {  
“capacity”: null,  
“controller\_id”: null,

.  
so on  
.

}  
},  
“msg”: “Successfully completed the view storage volume operation”,  
“storage\_status”: {  
“Message”: {

when I register, the output I get is just the “msg” block, whereas I wish to capture the invocation/module\_args block  
The module\_args block contains some information that I need to make use of.

I hope I was able to explain.

---

<div class="post-metadata">

**Author:** ![Shreya\_Bhardwaj](https://avatars.discourse-cdn.com/v4/letter/s/e79b87/32.png) [@Shreya\_Bhardwaj](https://forum.ansible.com/u/Shreya_Bhardwaj)\
**Post date:** [November 5, 2020, 6:50am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/4 "2020-11-05T06:50:49Z")

</div>

Any Updates on this please?

Thanks,  
Shreya Bhardwaj

---

<div class="post-metadata">

**Author:** ![Akasurde](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/akasurde/32/230_2.png) [@Akasurde](https://forum.ansible.com/u/Akasurde)\
**Post date:** [November 5, 2020, 7:06am UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/5 "2020-11-05T07:06:20Z")

</div>

Hi Shreya,

I am afraid that I am not aware of anything like this.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/ansible/original/1X/1882d9a01da5d8996a862359b0913cc568a39b84.svg) [@system](https://forum.ansible.com/u/system)\
**Post date:** [November 5, 2020, 5:45pm UTC](https://forum.ansible.com/t/how-to-capture-module-args-in-a-variable/34137/6 "2020-11-05T17:45:09Z")

</div>

This is not possible, mostly for security reasons, once in a variable  
we have no way to secure secrets/passwords flagged as 'no\_log' in the  
action itself.
