# Unable to running shell command on target host

**URL:** <https://forum.ansible.com/t/unable-to-running-shell-command-on-target-host/3940>\
**Category:** Get Help\
**Tags:** awx, ee\
**Created:** [February 19, 2024, 4:08am UTC](https://forum.ansible.com/t/unable-to-running-shell-command-on-target-host/3940 "2024-02-19T04:08:29Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dtio](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/dtio/32/2323_2.png) [@dtio](https://forum.ansible.com/u/dtio)\
**Post date:** [February 19, 2024, 4:08am UTC](https://forum.ansible.com/t/unable-to-running-shell-command-on-target-host/3940/1 "2024-02-19T04:08:29Z")

</div>

Hi All,

I notice that when using AAP/AWX with execution-envrionment, I was no longer able run command on the target machine. It seems like ansible.builtin.shell will actually perform the command within the execution environment. What is the official way of running command on the target machine with execution envrionment ?

Regards,

David Tio

---

<div class="post-metadata">

**Author:** ![Andersson007](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/andersson007/32/89_2.png) [@Andersson007](https://forum.ansible.com/u/Andersson007)\
**Post date:** [February 19, 2024, 9:05am UTC](https://forum.ansible.com/t/unable-to-running-shell-command-on-target-host/3940/2 "2024-02-19T09:05:56Z")

</div>

@dtio hi, yes, that’s correct as the control node -and playbooks respectively- now run inside the container, so now you need to treat your actual localhost as a remote target if you want to run tasks against it. Any other thoughts from experts?

BTW there’s a set of [Quick start docs](https://ansible.readthedocs.io/en/latest/getting_started_ee/) introduced last autumn, may be helpful.

---

<div class="post-metadata">

**Author:** ![jbericat](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/jbericat/32/627_2.png) [@jbericat](https://forum.ansible.com/u/jbericat)\
**Post date:** [February 19, 2024, 7:37pm UTC](https://forum.ansible.com/t/unable-to-running-shell-command-on-target-host/3940/3 "2024-02-19T19:37:49Z")

</div>

Hello @dtio welcome to Ansible Community Forum!

If I understood your inquiry correctly, what you want to do is to execute shell commands on a remote target (managed host), right?

If that’s so, it doesn’t matter if you’re using an EE on AWX (you can do the same with `ansible-navigator` in fact). The way to go is to create an inventory on your AWX / AAP instance with the target hosts on it, and then select this very same inventory on the Job Template that runs your playbook. You can also limit the execution to specific groups or hosts within the inventory using the `limit` option on the JT.

If you still have doubts about this, I can provide you with a simplified example.

Cheers!

PS: Also, consider using the `ansible.builtin.command` module instead of the `ansible.builtin.shell`, [as noted in the module documentation](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html#notes):

> If you want to execute a command securely and predictably, it may be better to use the [ansible.builtin.command](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html#ansible-collections-ansible-builtin-command-module) module instead. Best practices when writing playbooks will follow the trend of using [ansible.builtin.command](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/command_module.html#ansible-collections-ansible-builtin-command-module) unless the [ansible.builtin.shell](https://docs.ansible.com/ansible/latest/collections/ansible/builtin/shell_module.html#ansible-collections-ansible-builtin-shell-module) module is explicitly required. When running ad-hoc commands, use your best judgement
