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?
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.
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