Copy of Puppetmaster, except with WHD-CLI installed.
This Docker container is based on CentOS 6 and installs the Puppet master along with WHD-CLI.
This container sets the autosign policy to check_csr.py, which looks up the serial number in WebHelpDesk. If the serial number is found, it autosigns the Puppet certificate request.
This container is designed to be used with a data-only container, and thus all data is kept in /opt/puppet/ and /opt/varpuppet/lib/puppet/.
To use this container:
First, run a WebHelpDesk Docker container with
You'll need to use WebHelpDesk to generate an API key first for an account with permissions to read and edit all assets.
Copy and paste that API key into com.github.nmcspadden.whd-cli.plist. You can obtain the plist easily with curl:
curl -O https://raw.githubusercontent.com/macadmins/puppetmaster-whdcli/master/com.github.nmcspadden.whd-cli.plist
- For this example, I'm storing it on the Docker host in /home/nmcspadden/com.github.nmcspadden.whd-cli.plist. You can also fork this repo and the Dockerfile and build your own image with a pre-configured plist.
- Create a data-only container to store all Puppet dynamic and fixed data:
docker run -d --name puppet-data --entrypoint /bin/echo macadmins/puppetmaster-whdcli Data-only container for puppetmaster
This data-only container allows you to spin up & down and destroy the puppetmaster containers freely, with no loss of certificate data - all of that is stored inside puppet-data instead, which doesn't take up any system resources because it's not a running container.
To use with WHD container linking (preferred):
- The port for the whd_url key in the com.github.nmcspadden.whd-cli.plist must match that of the port WHD is using. By default, it's 8081. If you configure it with SSL, it's most likely using 8443. If you use the name "whd", the URL for linking is http://whd:8081/.
docker run -d --name puppetmaster -h puppet -p 8140:8140 --volumes-from puppet-data --link whd:whd -v /home/nmcspadden/com.github.nmcspadden.whd-cli.plist:/home/whdcli/com.github.nmcspadden.whd-cli.plist macadmins/puppetmaster-whdcli
- Critical step:
docker exec puppetmaster cp -Rf /etc/puppet /opt/
This step is necessary to populate /opt/puppet with all the correct directory structure for puppet to use. Because of the data-only container, this will not populate itself!
- You should be able to ping whd from within the Docker container:
docker exec puppetmaster ping whd
- See the section below to test the WHD-CLI hook.
docker exec puppetmaster puppet cert list -allto list all existing certs (only the default puppet cert should exist at startup).
- To test on a client:
- Install Puppet, Hiera, Facter, Facter-MacFacts (for OS X), and PuppetLaunchD on client.
- Install the CSR attributes on client. Without the CSR attributes, the serial number will not be checked and the certs will be autorejected!
- Add the Docker host IP to /etc/hosts as "puppet".
sudo puppet resource service com.puppetlabs.puppet ensure=running enable=true
- As root,
# puppet agent --testto generate the cert request.
- If the client's serial number exists as an asset in WebHelpDesk (and is not deleted), then the cert request should be autosigned.
docker logs puppetmasterto see the logs of the certificate request.
- You can check for more output from the script in /var/log/check_csr.out:
docker exec puppetmaster tail -n 500 /var/log/check_csr.out
- If you want more logging detail, you can set the log level in /etc/puppet/check_csr.py to DEBUG instead of INFO on line 10.
To use this image with direct HTTP/HTTPS:
- Change com.github.nmcspadden.whd-cli.plist's whd_url key to the web address of your WebHelpDesk instance. For example: "https://webhelpdesk.domain.org:8443" or "http://webhelpdesk.domain.com:8081"
- Run the container with this command:
docker run -d --name puppetmaster -h puppet -p 8140:8140 -v /home/nmcspadden/com.github.nmcspadden.whd-cli.plist:/home/whdcli/com.github.nmcspadden.whd-cli.plist --volumes-from puppet-data macadmins/puppetmaster-whdcli
Testing the WHD-CLI link:
- Run the container either with linking or direct as above.
- Run Python:
docker exec -it puppetmaster /usr/bin/python
- In Python:
>>> import whdcli
>>> whd_prefs = whdcli.WHDPrefs("/home/whdcli/com.github.nmcspadden.whd-cli.plist")
>>> w = whdcli.WHD(whd_prefs)
- If you get a traceback here, it'll tell you the reason why it failed (such as a bad address, bad API key, or other HTTP authentication failure).
- If it doesn't fail here, you can try to do a serial number lookup: