HiveBrain v1.2.0
Get Started
← Back to all entries
patternModerate

Is there an ansible module that check whether a port is not in LISTEN state?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
checklistenmodulethatstateporttherewhetheransiblenot

Problem

The Ansible module index has been consulted, but no module was found that checks whether a port is available? Is there a module that supports this?

What does available mean?

Available means that a port, e.g. 80 is not in LISTEN state. The following indicates that port 111 is unavailable.

user@localhost ~ $ ss -nat
State      Recv-Q Send-Q Local Address:Port    Peer Address:Port              
LISTEN     0      128       *:111                   *:*


What is the aim of this question?

The aim of this question is to find a way to stop an Ansible run when port 80 is already allocated by another process than certbot. Certbot requires port 80 to be available, otherwise the cert cannot be renewed. The issue can be found here.

Solution

I think you're looking for the wait_for module. It will allow you to check and make an action when a certain port is available and more.

Context

StackExchange DevOps Q#1275, answer score: 12

Revisions (0)

No revisions yet.