How to make Puppet track TCP ports to avoid conflicts?

72 views Asked by At

My puppet master has modules for many different services (mysql, redis, jenkins, beanstalk, etc.). Each module seems to have its own way of defining what port(s) the service listens on. Is there some unified way to track TCP ports across puppet modules? I would think there should be a resource type, like file, which enforces global uniqueness, but I don't see anything appropriate in the puppet docs

The idea is that if I accidentally configure two different services to listen on the same port, I should get an error about the conflict when compiling the catalog, not when the second service restarts on the node and gets EADDRINUSE.

1

There are 1 answers

0
Chris Pitman On

If all you want to do is catch conflicts, you can create a defined type. For example:

define port (
  $port = $name
) {
}

You can then use it to signal that a port is being used (eg port { 8080: }) and puppet will fail to compile a catalog if the same port is defined twice.