# Need to automate tasks via Bastion server

**URL:** <https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840>\
**Category:** AWX Project\
**Created:** [April 2, 2023, 9:26am UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840 "2023-04-02T09:26:37Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monica](https://avatars.discourse-cdn.com/v4/letter/m/a183cd/32.png) [@Monica](https://forum.ansible.com/u/Monica)\
**Post date:** [April 2, 2023, 9:26am UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840/1 "2023-04-02T09:26:37Z")

</div>

Hi All,

I have requirement to automate some tasks via ansible playbook, the problem is I cannot go to the serves directly I need to go to remote nodes via bastion node. Could anyone pls help how can I write the same inside inventory.

---

<div class="post-metadata">

**Author:** ![Wei-Yen\_Tan](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/wei-yen_tan/32/4111_2.png) [@Wei-Yen\_Tan](https://forum.ansible.com/u/Wei-Yen_Tan)\
**Post date:** [April 2, 2023, 11:41am UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840/2 "2023-04-02T11:41:36Z")

</div>

you can use delegate\_to. you could execution nodes strategy.  
[Ansible delegate\_to | How do the Ansible delegate\_to works? (educba.com)](https://www.educba.com/ansible-delegate_to/)

[awx/execution\_nodes.md at devel · ansible/awx (github.com)](https://github.com/ansible/awx/blob/devel/docs/execution_nodes.md)

this is documentation for execution nodes

---

<div class="post-metadata">

**Author:** ![Jose\_Osorio\_R](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jose\_Osorio\_R](https://forum.ansible.com/u/Jose_Osorio_R)\
**Post date:** [April 3, 2023, 6:39am UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840/3 "2023-04-03T06:39:41Z")

</div>

Hello Monica,

Here is the article that can explain it better [https://github.com/IBM/IBMDeveloper-recipes/blob/main/multiple-jumphosts-in-ansible-tower-part-1/index.md](https://github.com/IBM/IBMDeveloper-recipes/blob/main/multiple-jumphosts-in-ansible-tower-part-1/index.md)

In the inventory (group or host) you should add this:

for unix

ansible\_ssh\_common\_args: ‘-o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null -o ProxyCommand=“ssh -W %h:%p -p {{ jh\_ssh\_port }} {{ jh\_ssh\_user }}@{{ jh\_ip }} -i $JH\_SSH\_PRIVATE\_KEY -o StrictHostKeyChecking=no -o UserKnownHostsFile=/dev/null”’

regards

jose osorio

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [April 5, 2023, 6:51pm UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840/4 "2023-04-05T18:51:44Z")

</div>

Hi,  
We don’t have any official docs on this exact situation, but this blog post might help point you in the right direction: [https://www.jeffgeerling.com/blog/2022/using-ansible-playbook-ssh-bastion-jump-host](https://www.jeffgeerling.com/blog/2022/using-ansible-playbook-ssh-bastion-jump-host)  
-AWX Team

---

<div class="post-metadata">

**Author:** ![AWX\_Project](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AWX\_Project](https://forum.ansible.com/u/AWX_Project)\
**Post date:** [April 5, 2023, 6:52pm UTC](https://forum.ansible.com/t/need-to-automate-tasks-via-bastion-server/37840/5 "2023-04-05T18:52:33Z")

</div>

Hi there,  
We actually do have docs, I just missed them: [https://docs.ansible.com/automation-controller/latest/html/administration/tipsandtricks.html#setting-up-a-jump-host-to-use-with-the-controller](https://docs.ansible.com/automation-controller/latest/html/administration/tipsandtricks.html#setting-up-a-jump-host-to-use-with-the-controller)  
again, good luck!  
-AWX Team
