# Right way to pass a command to command module when using \_execute\_module in custom action plugin

**URL:** <https://forum.ansible.com/t/right-way-to-pass-a-command-to-command-module-when-using-execute-module-in-custom-action-plugin/28532>\
**Category:** Ansible Developer\
**Created:** [September 8, 2018, 2:47pm UTC](https://forum.ansible.com/t/right-way-to-pass-a-command-to-command-module-when-using-execute-module-in-custom-action-plugin/28532 "2018-09-08T14:47:12Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sankaravadivel\_S](https://avatars.discourse-cdn.com/v4/letter/s/b5a626/32.png) [@Sankaravadivel\_S](https://forum.ansible.com/u/Sankaravadivel_S)\
**Post date:** [September 8, 2018, 2:47pm UTC](https://forum.ansible.com/t/right-way-to-pass-a-command-to-command-module-when-using-execute-module-in-custom-action-plugin/28532/1 "2018-09-08T14:47:12Z")

</div>

I am building a custom action plugin and I am trying to invoke the command module using ActionBase.\_execute\_module. But unfortunately, I couldn’t find any document or samples showing how to pass the command to module\_args parameter. I set \_raw\_params value to my command and got it working. But I am not sure if that is the recommended approach. Below is the code I am talking about. It would be great if someone could point me to the right usage of this module programmatically

cmd = ‘ls -a’  
command\_task.args[“\_raw\_params”] = cmd  
command\_task.args[‘\_uses\_shell’] = True  
module\_return = self.\_execute\_module(module\_name=‘command’, module\_args=command\_task.args, task\_vars=task\_vars)
