How to use SSH tunnel in ansible to provide internet access to a server [closed]
Sophia Terry
We have few servers in a DC which are not connected to the internet (accessible only via vpn), Sometimes we need to update the time in servers using htpdate, Right now we do it by creating a ssh tunnel and squid proxy (see below commands)
ssh root@192.168.30.10 -R3128:localhost:3128
export http_proxy='
htpdate -da -l -P localhost:3128 3.in.pool.ntp.org 1.asia.pool.ntp.org 3.asia.pool.ntp.org
export http_proxy=' 'How can I automate this with ansible ?
21 Answer
You can add any SSH args via ansible_ssh_extra_args or companions (see doc).
Inventory:
remote-host ansible_host=192.168.30.10 ansible_ssh_extra_args="-R3128:localhost:3128"Playbook:
- hosts: remote-host environment: http_proxy: tasks: - command: htpdate -da -l -P localhost:3128 3.in.pool.ntp.org 1.asia.pool.ntp.org 3.asia.pool.ntp.org 3