diff --git a/puppetserver/docker-entrypoint.d/20-use-templates-initially.sh b/puppetserver/docker-entrypoint.d/20-use-templates-initially.sh index b37a77a7..c275e55d 100755 --- a/puppetserver/docker-entrypoint.d/20-use-templates-initially.sh +++ b/puppetserver/docker-entrypoint.d/20-use-templates-initially.sh @@ -1,4 +1,6 @@ -#! /bin/bash +#!/bin/bash + +set -e # During build, pristine config files get copied to this directory. If # they are not in the current container, use these templates as the diff --git a/puppetserver/docker-entrypoint.d/30-set-permissions.sh b/puppetserver/docker-entrypoint.d/30-set-permissions.sh index 8fbbaab0..9fcf936e 100755 --- a/puppetserver/docker-entrypoint.d/30-set-permissions.sh +++ b/puppetserver/docker-entrypoint.d/30-set-permissions.sh @@ -1,4 +1,6 @@ -#! /bin/bash +#!/bin/bash + +set -e chown -R puppet:puppet /etc/puppetlabs/puppet/ chown -R puppet:puppet /opt/puppetlabs/server/data/puppetserver/ diff --git a/puppetserver/docker-entrypoint.d/40-update-puppetdb-conf.sh b/puppetserver/docker-entrypoint.d/40-update-puppetdb-conf.sh index 3cd7b35f..b05b567c 100755 --- a/puppetserver/docker-entrypoint.d/40-update-puppetdb-conf.sh +++ b/puppetserver/docker-entrypoint.d/40-update-puppetdb-conf.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if test -n "${PUPPETDB_SERVER_URLS}" ; then sed -i "s@^server_urls.*@server_urls = ${PUPPETDB_SERVER_URLS}@" /etc/puppetlabs/puppet/puppetdb.conf fi diff --git a/puppetserver/docker-entrypoint.d/50-set-certname.sh b/puppetserver/docker-entrypoint.d/50-set-certname.sh index c866222e..c86f32d7 100755 --- a/puppetserver/docker-entrypoint.d/50-set-certname.sh +++ b/puppetserver/docker-entrypoint.d/50-set-certname.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if [ -n "${PUPPETSERVER_HOSTNAME}" ]; then /opt/puppetlabs/bin/puppet config set server "$PUPPETSERVER_HOSTNAME" fi diff --git a/puppetserver/docker-entrypoint.d/55-set-masterport.sh b/puppetserver/docker-entrypoint.d/55-set-masterport.sh index 197bd5e2..be8198cf 100755 --- a/puppetserver/docker-entrypoint.d/55-set-masterport.sh +++ b/puppetserver/docker-entrypoint.d/55-set-masterport.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + hocon() { /opt/puppetlabs/puppet/lib/ruby/vendor_gems/bin/hocon "$@" } diff --git a/puppetserver/docker-entrypoint.d/56-set-environmentpath.sh b/puppetserver/docker-entrypoint.d/56-set-environmentpath.sh index 7fb17245..6f631e89 100755 --- a/puppetserver/docker-entrypoint.d/56-set-environmentpath.sh +++ b/puppetserver/docker-entrypoint.d/56-set-environmentpath.sh @@ -1,4 +1,5 @@ #!/bin/bash -# -puppet config set --section server environmentpath $ENVIRONMENTPATH +set -e + +puppet config set --section server environmentpath $ENVIRONMENTPATH diff --git a/puppetserver/docker-entrypoint.d/57-set-hiera_config.sh b/puppetserver/docker-entrypoint.d/57-set-hiera_config.sh index edb5e447..4fc44c87 100755 --- a/puppetserver/docker-entrypoint.d/57-set-hiera_config.sh +++ b/puppetserver/docker-entrypoint.d/57-set-hiera_config.sh @@ -1,4 +1,5 @@ #!/bin/bash -# -puppet config set --section server hiera_config $HIERACONFIG +set -e + +puppet config set --section server hiera_config $HIERACONFIG diff --git a/puppetserver/docker-entrypoint.d/60-setup-autosign.sh b/puppetserver/docker-entrypoint.d/60-setup-autosign.sh index 3f7c6bf1..55fab1fc 100755 --- a/puppetserver/docker-entrypoint.d/60-setup-autosign.sh +++ b/puppetserver/docker-entrypoint.d/60-setup-autosign.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # Configure puppet to use a certificate autosign script (if it exists) # AUTOSIGN=true|false|path_to_autosign.conf if test -n "${AUTOSIGN}" ; then diff --git a/puppetserver/docker-entrypoint.d/70-set-dns-alt-names.sh b/puppetserver/docker-entrypoint.d/70-set-dns-alt-names.sh index 4fae9081..cb3a52d7 100755 --- a/puppetserver/docker-entrypoint.d/70-set-dns-alt-names.sh +++ b/puppetserver/docker-entrypoint.d/70-set-dns-alt-names.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + # Allow setting dns_alt_names for the compilers certificate. This # setting will only have an effect when the container is started without # an existing certificate on the /etc/puppetlabs/puppet volume diff --git a/puppetserver/docker-entrypoint.d/83-environment-cache.sh b/puppetserver/docker-entrypoint.d/83-environment-cache.sh index 79904af6..307e79a1 100755 --- a/puppetserver/docker-entrypoint.d/83-environment-cache.sh +++ b/puppetserver/docker-entrypoint.d/83-environment-cache.sh @@ -1,5 +1,7 @@ #!/bin/bash -# + +set -e + if [ -n "$PUPPETSERVER_ENVIRONMENT_TIMEOUT" ]; then echo "Settings environment_timeout to ${PUPPETSERVER_ENVIRONMENT_TIMEOUT}" puppet config set --section server environment_timeout $PUPPETSERVER_ENVIRONMENT_TIMEOUT diff --git a/puppetserver/docker-entrypoint.d/84-enable_graphite.sh b/puppetserver/docker-entrypoint.d/84-enable_graphite.sh index 9e3ea4a6..08e4147e 100755 --- a/puppetserver/docker-entrypoint.d/84-enable_graphite.sh +++ b/puppetserver/docker-entrypoint.d/84-enable_graphite.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + if [[ "$PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED" == "true" ]]; then if [[ -n "$PUPPETSERVER_GRAPHITE_HOST" && -n "$PUPPETSERVER_GRAPHITE_PORT" ]]; then echo "Enabling graphite exporter" @@ -9,4 +11,3 @@ if [[ "$PUPPETSERVER_GRAPHITE_EXPORTER_ENABLED" == "true" ]]; then exit 99 fi fi - diff --git a/puppetserver/docker-entrypoint.d/85-setup-storeconfigs.sh b/puppetserver/docker-entrypoint.d/85-setup-storeconfigs.sh index 6ac39659..2d7a7332 100755 --- a/puppetserver/docker-entrypoint.d/85-setup-storeconfigs.sh +++ b/puppetserver/docker-entrypoint.d/85-setup-storeconfigs.sh @@ -1,5 +1,7 @@ #!/bin/sh +set -e + if [ -n "$PUPPET_STORECONFIGS_BACKEND" ]; then puppet config set storeconfigs_backend $PUPPET_STORECONFIGS_BACKEND --section master fi diff --git a/puppetserver/docker-entrypoint.d/88-enable-cache-delete-api.sh b/puppetserver/docker-entrypoint.d/88-enable-cache-delete-api.sh index a1f36bb0..a265e87f 100755 --- a/puppetserver/docker-entrypoint.d/88-enable-cache-delete-api.sh +++ b/puppetserver/docker-entrypoint.d/88-enable-cache-delete-api.sh @@ -1,5 +1,7 @@ #!/bin/bash -# + +set -e + if [[ "$PUPPETSERVER_ENABLE_ENV_CACHE_DEL_API" == true ]]; then if [[ $(grep 'puppet-admin-api' /etc/puppetlabs/puppetserver/conf.d/auth.conf) ]]; then echo "Admin API already set" diff --git a/puppetserver/docker-entrypoint.d/89-csr_attributes.rb b/puppetserver/docker-entrypoint.d/89-csr_attributes.rb index 1a5419d2..3109f31e 100755 --- a/puppetserver/docker-entrypoint.d/89-csr_attributes.rb +++ b/puppetserver/docker-entrypoint.d/89-csr_attributes.rb @@ -5,11 +5,10 @@ begin csr_yaml = YAML.dump(JSON.load(ENV['CSR_ATTRIBUTES'])) - File.open('/etc/puppetlabs/puppet/csr_attributes.yaml', 'w') do |file| - file.write(csr_yaml) - end + File.write('/etc/puppetlabs/puppet/csr_attributes.yaml', csr_yaml) rescue => error puts "Error on reading JSON env. Terminating" + puts "Malformed JSON: #{ENV['CSR_ATTRIBUTES']}" p error.message exit 99 end diff --git a/puppetserver/docker-entrypoint.d/89-csr_attributes.sh b/puppetserver/docker-entrypoint.d/89-csr_attributes.sh index 4b1ebfc3..4ed87146 100755 --- a/puppetserver/docker-entrypoint.d/89-csr_attributes.sh +++ b/puppetserver/docker-entrypoint.d/89-csr_attributes.sh @@ -1,3 +1,6 @@ #!/bin/bash -echo $CSR_ATTRIBUTES + +set -e + +echo "CSR Attributes: ${CSR_ATTRIBUTES}" /opt/puppetlabs/puppet/bin/ruby /docker-entrypoint.d/89-csr_attributes.rb diff --git a/puppetserver/docker-entrypoint.d/90-ca.sh b/puppetserver/docker-entrypoint.d/90-ca.sh index 11f7b45b..50075dcd 100755 --- a/puppetserver/docker-entrypoint.d/90-ca.sh +++ b/puppetserver/docker-entrypoint.d/90-ca.sh @@ -1,5 +1,7 @@ #!/bin/bash +set -e + ca_running() { status=$(curl --silent --fail --insecure "https://${CA_HOSTNAME}:${CA_PORT:-8140}/status/v1/simple") test "$status" = "running" diff --git a/puppetserver/docker-entrypoint.d/99-log-config.sh b/puppetserver/docker-entrypoint.d/99-log-config.sh index bdd3563d..cc72c47f 100755 --- a/puppetserver/docker-entrypoint.d/99-log-config.sh +++ b/puppetserver/docker-entrypoint.d/99-log-config.sh @@ -1,5 +1,7 @@ #! /bin/sh +set -e + ### Print configuration for troubleshooting echo "System configuration values:" # shellcheck disable=SC2039 # Docker injects $HOSTNAME