Skip to content

Commit

Permalink
(maint) Allow .internal domain to be configurable
Browse files Browse the repository at this point in the history
 - Modify compose to use either the ENV variable DOMAIN supplied
   by an end user or to fall back to `internal` when its left
   unspecified.
  • Loading branch information
Iristyle committed May 6, 2019
1 parent 615b997 commit c11e435
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 16 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
28 changes: 14 additions & 14 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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:
Expand All @@ -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}
4 changes: 2 additions & 2 deletions spec/dockerfile_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c11e435

Please sign in to comment.