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

16 views
Skip to first unread message

yuech...@gmail.com

unread,
Jan 22, 2019, 11:16:04 AM1/22/19
to Ansible Project
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
Tasks:
- include: inner playbook.yml
inner playbook:
- hosts: HostB
Tasks:
....
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?

Kai Stian Olstad

unread,
Jan 22, 2019, 3:28:48 PM1/22/19
to ansible...@googlegroups.com
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.

--
Kai Stian Olstad


cyril...@zi.uzh.ch

unread,
Jan 23, 2019, 12:04:42 PM1/23/19
to Ansible Project
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) on Host A where you execute ansible-playbook with the playbook(s) you wrote for Host B.

Hope that helps, regards,
Cyril
Reply all
Reply to author
Forward
0 new messages