我必须建立到不同服务器的两个VPN连接,然后执行六个端口转发命令。目前,我手动为每个操作打开一个控制台,以便它们并行运行。我想将所有这些动作做成Ansible剧本。
我尝试尝试的ansible文件使用异步:25200(秒)来解决7个小时的连接
---
- name: start of the day tasks on localhost
hosts: 127.0.0.1
connection: local
become: yes
tasks:
- name: start Kerio and connect to server1 VPN
shell: /etc/init.d/kerio-kvc start; ssh user@server1_ip
- name: connect to server_2 VPN
shell: ssh user@server2_ip
async: 25200
poll: 0
- name: instantiate RabbitMQ in server_1
shell: ssh -L 5680:localhost:5672 user@server1_ip
async: 25200
poll: 0
- name: instantiate RabbitMQ in server_2
shell: ssh -L 5690:localhost:5672 user@server2_ip
async: 25200
poll: 0