Simple multiplayer design

I would like to run an unoccupied play on a target host passing through several hosts. The scenario is similar to the one shown in the picture:

enter image description here

I partially solved the problem by creating the ssh_config file in the Ansible project directory:

 Host IP_HostN HostName IP_HOST_N ProxyJump Username1@IP _HOST_2:22, Username2@IP _HOST_2:22 User UsernameN 

and defining in ansible.cfg in the Ansible project directory:

 [ssh_connection] ssh_args= -F "ssh_config" 

The problem is that I need to automatically insert a username and password for each temporary host and target ssh host, and I don't know how to automate this task. In addition, python cannot be installed for every node transient.

+5
source share
1 answer

I found a fairly good workaround. According to the following scenario:

enter image description here

we create an ssh tunnel to a temporary host that can directly reach the target host. We also create a local port binding with the -L flag:

 ssh -J user_1@transient _host1:port_1 -p port_2 user_2@transient _host2 -L LOCAL_PORT:TARGET_HOST_IP:TARGET_HOST_PORT 

Then we can directly enter the Target Host using local binding:

 ssh user_target_host@localhost -p LOCAL_PORT 

Thus, we can run available text books for the local host by setting the necessary variables:

 ansible_host: localhost ansible_user: user_target_host ansible_port: LOCAL_PORT ansible_password: password_target_host 
+1
source

Source: https://habr.com/ru/post/1273402/


All Articles