From c11e43521518ad677e3a00c6cd05e697cb0a58cb Mon Sep 17 00:00:00 2001 From: Iristyle Date: Fri, 3 May 2019 16:55:32 -0700 Subject: [PATCH] (maint) Allow .internal domain to be configurable - Modify compose to use either the ENV variable DOMAIN supplied by an end user or to fall back to `internal` when its left unspecified. --- README.md | 9 +++++++++ docker-compose.yml | 28 ++++++++++++++-------------- spec/dockerfile_spec.rb | 4 ++-- 3 files changed, 25 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 20cf9bea..19270bbe 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,15 @@ is placed into the server's SSL certificate. If you need to change it after that, you will need to properly revoke the server's certificate and restart the stack with the changed `DNS_ALT_NAMES` value. +Optionally, you may also provide a desired `DOMAIN` value, other than default +value of `internal` to further define how the service hosts are named. It is +not necessary to change `DNS_ALT_NAMES` as the default value already takes into +account any custom domain. + +``` + DOMAIN=foo docker-compose up -d +``` + When you first start the Puppet Infrastructure, the stack will create a `volumes/` directory with a number of sub-directories to store the persistent data that should survive the restart of your infrastructure. This diff --git a/docker-compose.yml b/docker-compose.yml index efae8803..dd7420e5 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,30 +2,30 @@ version: '3' services: puppet: - hostname: puppet.internal + hostname: puppet.${DOMAIN:-internal} image: puppet/puppetserver ports: - 8140:8140 environment: # necessary to set certname and server in puppet.conf, required by # puppetserver ca cli application - - PUPPETSERVER_HOSTNAME=puppet.internal + - PUPPETSERVER_HOSTNAME=puppet.${DOMAIN:-internal} # DNS_ALT_NAMES must be set before starting the stack the first time, # and must list all the names under which the puppetserver can be - # reached. 'puppet.internal' must be one of them, otherwise puppetdb won't be + # reached. 'puppet.${DOMAIN:-internal}' must be one of them, otherwise puppetdb won't be # able to get a cert. Add other names as a comma-separated list - - DNS_ALT_NAMES=puppet,puppet.internal,${DNS_ALT_NAMES:-} + - DNS_ALT_NAMES=puppet,puppet.${DOMAIN:-internal},${DNS_ALT_NAMES:-} - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-true} - - PUPPETDB_SERVER_URLS=https://puppetdb.internal:8081 + - PUPPETDB_SERVER_URLS=https://puppetdb.${DOMAIN:-internal}:8081 volumes: - ${VOLUME_ROOT:-.}/volumes/code:/etc/puppetlabs/code/ - ${VOLUME_ROOT:-.}/volumes/puppet:/etc/puppetlabs/puppet/ - ${VOLUME_ROOT:-.}/volumes/serverdata:/opt/puppetlabs/server/data/puppetserver/ - dns_search: internal + dns_search: ${DOMAIN:-internal} networks: default: aliases: - - puppet.internal + - puppet.${DOMAIN:-internal} postgres: image: postgres:9.6 @@ -38,20 +38,20 @@ services: volumes: - ${VOLUME_ROOT:-.}/volumes/puppetdb-postgres/data:/var/lib/postgresql/data - ./postgres-custom:/docker-entrypoint-initdb.d - dns_search: internal + dns_search: ${DOMAIN:-internal} networks: default: aliases: - - postgres.internal + - postgres.${DOMAIN:-internal} puppetdb: - hostname: puppetdb.internal + hostname: puppetdb.${DOMAIN:-internal} image: puppet/puppetdb environment: - PUPPERWARE_ANALYTICS_ENABLED=${PUPPERWARE_ANALYTICS_ENABLED:-true} # This name is an FQDN so the short name puppet doesn't collide outside compose network - - PUPPETSERVER_HOSTNAME=puppet.internal - - PUPPETDB_POSTGRES_HOSTNAME=postgres.internal + - PUPPETSERVER_HOSTNAME=puppet.${DOMAIN:-internal} + - PUPPETDB_POSTGRES_HOSTNAME=postgres.${DOMAIN:-internal} - PUPPETDB_PASSWORD=puppetdb - PUPPETDB_USER=puppetdb ports: @@ -62,8 +62,8 @@ services: - puppet volumes: - ${VOLUME_ROOT:-.}/volumes/puppetdb/ssl:/etc/puppetlabs/puppet/ssl/ - dns_search: internal + dns_search: ${DOMAIN:-internal} networks: default: aliases: - - puppetdb.internal + - puppetdb.${DOMAIN:-internal} diff --git a/spec/dockerfile_spec.rb b/spec/dockerfile_spec.rb index c56faa82..e3d23a56 100644 --- a/spec/dockerfile_spec.rb +++ b/spec/dockerfile_spec.rb @@ -14,9 +14,9 @@ ] before(:all) do - # append .internal to ensure domain suffix for Docker DNS resolver is used + # append .internal (or user domain) to ensure domain suffix for Docker DNS resolver is used # since search domains are not appended to /etc/resolv.conf - @test_agent = "puppet_test#{Random.rand(1000)}.internal" + @test_agent = "puppet_test#{Random.rand(1000)}.#{ENV['DOMAIN'] || 'internal'}" @timestamps = [] status = run_command('docker-compose --no-ansi version')[:status] if status.exitstatus != 0