Skip to content

Commit 242190a

Browse files
authored
Use PUPPETSERVER_HOSTNAME as certname if set (#2470)
Previously when logging the container's configuration, the certname was retrieved from `${SSLDIR}/certs`. This could lead to a `file not found` issue when printing the configuration if that directory contained more than one certificate. Since the `PUPPETSERVER_HOSTNAME` environment variable is used to configure the certname for puppetserver anyway, this commit updates the logging to use that if it is set, and only fall back to searching the dir if it's not configured.
1 parent 759736e commit 242190a

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

docker/puppetserver/docker-entrypoint.d/90-log-config.sh

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,15 @@ echo "System configuration values:"
55
# shellcheck disable=SC2039 # Docker injects $HOSTNAME
66
echo "* HOSTNAME: '${HOSTNAME}'"
77
echo "* hostname -f: '$(hostname -f)'"
8-
echo "* PUPPETSERVER_HOSTNAME:PUPPET_MASTERPORT: '${PUPPETSERVER_HOSTNAME}:${PUPPET_MASTERPORT}'"
9-
certname=$(cd "${SSLDIR}/certs" && ls *.pem | grep --invert-match ca.pem)
10-
echo "* Generated certname: '${certname}'"
8+
if test -n "${PUPPETSERVER_HOSTNAME}"; then
9+
echo "* PUPPETSERVER_HOSTNAME: '${PUPPETSERVER_HOSTNAME}'"
10+
certname=${PUPPETSERVER_HOSTNAME}.pem
11+
else
12+
echo "* PUPPETSERVER_HOSTNAME: unset"
13+
certname=$(cd "${SSLDIR}/certs" && ls *.pem | grep --invert-match ca.pem)
14+
fi
15+
echo "* PUPPET_MASTERPORT: '${PUPPET_MASTERPORT}'"
16+
echo "* Certname: '${certname}'"
1117
echo "* DNS_ALT_NAMES: '${DNS_ALT_NAMES}'"
1218
echo "* SSLDIR: '${SSLDIR}'"
1319

0 commit comments

Comments
 (0)