Hi all,
So I know how to do this for the most part, but I’ve got two servers that when I have to reboot them, one needs to be done before the other and cannot before a specific port comes available. That port is only accessible from that second server, not the ansible server itself. Does that make sense?
Is there a way that I can create a playbook that will do what I’m describing?
ie
Reboot server1
Reboot server2 when tcp/3306 comes available on server1. tcp/3306 is only open to server2.
Use the reboot module on server1, it will wait for the server to be available again.
Then in the next task you can use the wait_for module on server2 to check the port 3306.
Pseudo code for 2 play in one playbook.
- hosts: server1
tasks:
- reboot:
- hosts: server2
tasks:
- wait_for:
host: server1
port: 3306
state: started
- reboot:
or in one play
- hosts: server1,server2
tasks:
- reboot:
when: inventory_hostname == "server1"
- wait_for:
host: server1
port: 3306
state: started
when: inventory_hostname == "server2"
- reboot:
when: inventory_hostname == "server2"
Doesn’t this use the ansible server running the playbook to check if the port is open?