# How to write playbook to access to servers that ansible master can not access directly?

**URL:** <https://forum.ansible.com/t/how-to-write-playbook-to-access-to-servers-that-ansible-master-can-not-access-directly/29497>\
**Category:** Ansible Project\
**Created:** [January 22, 2019, 4:16pm UTC](https://forum.ansible.com/t/how-to-write-playbook-to-access-to-servers-that-ansible-master-can-not-access-directly/29497 "2019-01-22T16:16:03Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yuechengww](https://avatars.discourse-cdn.com/v4/letter/y/f05b48/32.png) [@yuechengww](https://forum.ansible.com/u/yuechengww)\
**Post date:** [January 22, 2019, 4:16pm UTC](https://forum.ansible.com/t/how-to-write-playbook-to-access-to-servers-that-ansible-master-can-not-access-directly/29497/1 "2019-01-22T16:16:03Z")

</div>

Ansible master -ssh- hostA -ssh- hostB, ansible master can not access HostB directly.  
If I want to deploy services on hostB, can I configure hostA in a playbook, and include another playbook with hostB?  
E.g - hosts: HostA  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- include: inner playbook.yml  
inner playbook:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;- hosts: HostB  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Tasks:  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;....  
Actually, the method of playbook does not work. I don’t want to use ssh proxy though it works. Does anyone else can give me with some suggestion?

---

<div class="post-metadata">

**Author:** ![Kai\_Stian\_Olstad](https://avatars.discourse-cdn.com/v4/letter/k/e19adc/32.png) [@Kai\_Stian\_Olstad](https://forum.ansible.com/u/Kai_Stian_Olstad)\
**Post date:** [January 22, 2019, 8:28pm UTC](https://forum.ansible.com/t/how-to-write-playbook-to-access-to-servers-that-ansible-master-can-not-access-directly/29497/2 "2019-01-22T20:28:38Z")

</div>

It's been on the list many times and you also find a lot of articles on Internet.

Search for bastion, jumphost, proxycommand and/or proxyjump.

---

<div class="post-metadata">

**Author:** ![cyril.stoll1](https://avatars.discourse-cdn.com/v4/letter/c/f07891/32.png) [@cyril.stoll1](https://forum.ansible.com/u/cyril.stoll1)\
**Post date:** [January 23, 2019, 5:04pm UTC](https://forum.ansible.com/t/how-to-write-playbook-to-access-to-servers-that-ansible-master-can-not-access-directly/29497/3 "2019-01-23T17:04:42Z")

</div>

Hi

Frankly I’m not sure if this is a good solution (or if it even works, though I don’t see why not). So my suggestion would be to have your local Ansible stuff (playbook, roles, etc.) install Ansible on Host A and push the playbooks etc. that you need to configure Host B onto Host A. In that way your Host A is to Host B what your local Computer is to Host A.  
Then at the end of deploying all that Stuff for Host B onto Host A you simply execute a shell command ([https://docs.ansible.com/ansible/latest/modules/shell\_module.html](https://docs.ansible.com/ansible/latest/modules/shell_module.html)) on Host A where you execute ansible-playbook with the playbook(s) you wrote for Host B.

Hope that helps, regards,  
Cyril
