Skip to content

Instantly share code, notes, and snippets.

@antonioabelgc
Last active March 25, 2024 13:24
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save antonioabelgc/16c1d4e87dba353ee620faeba5f00f92 to your computer and use it in GitHub Desktop.
Save antonioabelgc/16c1d4e87dba353ee620faeba5f00f92 to your computer and use it in GitHub Desktop.
This Gist provides a Docker Compose file for setting up a Puppet infrastructure with Puppet Server, Puppet DB, PostgreSQL, and Puppetboard services.

README

This gist contains a Docker Compose file that sets up a Puppet infrastructure with Puppet Server, Davidphay/PuppetDB, PostgreSQL, and Voxpupuli/Puppetboard services.

Description

The services are linked together through environment variables, and a health check is implemented to ensure that the infrastructure is running smoothly.

  • The Puppetboard service is available on http://localhost:80, providing a web interface for Puppet management and monitoring.
  • The Puppet Server can be accessed via :8140 port, serving as the central control point for Puppet agents.
  • Additionally, we can also find the information provided by PuppetDB at http://localhost:8080.

Usage

To use this gist, follow these steps:

  1. Download the Docker Compose file.

  2. Open a terminal and navigate to the directory where the Docker Compose file is located.

  3. Run the following command to start the Puppet infrastructure:

docker-compose up -d

This command will create three volumes to store the data for Puppet DB, PostgreSQL, and Puppet Server. The volumes will be initialized in the working directory.

Additionally, the ./puppetserver/code directory is used to store the Puppet manifests. You can place your Puppet code in this directory.

version: '3.3'
services:
puppetserver:
hostname: puppetserver
container_name: puppetserver
image: puppet/puppetserver
ports:
- "8140:8140"
volumes:
- './puppetserver/code:/etc/puppetlabs/code/'
- './puppetserver/puppet:/etc/puppetlabs/puppet/'
- './puppetserver/puppet/ssl/ca:/etc/puppetlabs/puppetserver/ca'
- './puppetserver/serverdata:/opt/puppetlabs/server/data/puppetserver/'
healthcheck:
test: curl --fail -k https://localhost:8140/status/v1/simple || exit 1
interval: 30s
timeout: 15s
retries: 6
environment:
- PUPPETSERVER_HOSTNAME=puppetserver
- PUPPET_MASTERPORT=8140
- DNS_ALT_NAMES=puppetserver
- USE_PUPPETDB=true
- PUPPETDB_SERVER_URLS=https://puppetdb:8081
postgres:
hostname: postgres
container_name: postgres
image: postgres:11-alpine
volumes:
- ./pgdata:/var/lib/postgresql/data/
environment:
- POSTGRES_PASSWORD=yoursecurepostgrespassword
- POSTGRES_USER=yourpuppetdbuser
- POSTGRES_DB=yourpuppetdbname
healthcheck:
test: pg_isready || exit 1
interval: 30s
timeout: 15s
retries: 6
puppetdb:
hostname: puppetdb
container_name: puppetdb
image: davidphay/puppetdb:7.12.1
depends_on:
puppetserver:
condition: service_healthy
postgres:
condition: service_healthy
volumes:
- ./puppetdb_data:/opt/puppetlabs/server/data/puppetdb
healthcheck:
test: curl --fail http://localhost:8080/status/v1/services/puppetdb-status || exit 1
interval: 30s
timeout: 15s
retries: 6
ports:
- 8080:8080
environment:
- PUPPETDB_PASSWORD=yoursecurepostgrespassword
- PUPPETDB_USER=yourpuppetdbuser
- PUPPETDB_POSTGRES_DATABASE=yourpuppetdbname
- PUPPETDB_POSTGRES_HOSTNAME=postgres
- PUPPETDB_POSTGRES_PORT=5432
- PUPPETSERVER_PORT=8140
- PUPPETSERVER_HOSTNAME=puppetserver
- USE_PUPPETSERVER=true
puppetboard:
hostname: puppetboard
container_name: puppetboard
image: ghcr.io/voxpupuli/puppetboard:latest
links:
- puppetdb
ports:
- "80:80"
depends_on:
puppetdb:
condition: service_healthy
environment:
- PUPPETDB_HOST=puppetdb
- PUPPETDB_PORT=8080
- PUPPETBOARD_PORT=80
- SECRET_KEY=yourverylongssecretkeystring
healthcheck:
test: wget http://127.0.0.1:80/status -O - || exit 1
interval: 30s
timeout: 15s
retries: 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment