diff --git a/README.md b/README.md index 96fe4bed..52c0c232 100644 --- a/README.md +++ b/README.md @@ -91,6 +91,7 @@ The following environment variables are supported: | **PUPPETSERVER_ENABLE_ENV_CACHE_DEL_API** | Enable the puppet admin api endpoint via certificates to allow clearing environment caches

Defaults to `true` | | **ENVIRONMENTPATH** | Set an environmentpath

Defaults to `/etc/puppetlabs/code/environments` | | **HIERACONFIG** | Set a hiera_config entry in puppet.conf file

Defaults to `$confdir/hiera.yaml` | +| **CSR_ATTRIBUTES** | Provide a JSON string of the csr_attributes.yaml content. e.g. CSR_ATTRIBUTES='{"custom_attributes": { "challengePassword": "foobar" }, "extension_requests": { "pp_project": "foo" } }'

Defaults to empty JSON object '{}'
Please note that within a compose file, you must quote the whole line
- 'CSR_ATTRIBUTES={ ...}' | ## Initialization Scripts diff --git a/puppetserver/Dockerfile b/puppetserver/Dockerfile index a2090bbc..33e8f385 100644 --- a/puppetserver/Dockerfile +++ b/puppetserver/Dockerfile @@ -44,7 +44,8 @@ ENV PUPPETSERVER_JAVA_ARGS="-Xms1024m -Xmx1024m" \ PUPPETSERVER_ENVIRONMENT_TIMEOUT=unlimited \ PUPPETSERVER_ENABLE_ENV_CACHE_DEL_API=true \ ENVIRONMENTPATH=/etc/puppetlabs/code/environments \ - HIERACONFIG="$confdir/hiera.yaml" + HIERACONFIG="$confdir/hiera.yaml" \ + CSR_ATTRIBUTES='{}' # NOTE: this is just documentation on defaults EXPOSE 8140 diff --git a/puppetserver/docker-entrypoint.d/89-csr_attributes.rb b/puppetserver/docker-entrypoint.d/89-csr_attributes.rb new file mode 100755 index 00000000..714b3baa --- /dev/null +++ b/puppetserver/docker-entrypoint.d/89-csr_attributes.rb @@ -0,0 +1,15 @@ +#!/opt/puppetlabs/puppet/bin/ruby + +require 'json' +require 'yaml' + +begin + csr_yaml = YAML.dump(JSON.load(ENV['CSR_ATTRIBUTES'])) + File.open('/etc/puppetlabs/puppet/csr_attrbitues.yaml', 'w') do |file| + file.write(csr_yaml) + end +rescue => error + puts "Error on reading JSON env. Terminating" + 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 new file mode 100755 index 00000000..4b1ebfc3 --- /dev/null +++ b/puppetserver/docker-entrypoint.d/89-csr_attributes.sh @@ -0,0 +1,3 @@ +#!/bin/bash +echo $CSR_ATTRIBUTES +/opt/puppetlabs/puppet/bin/ruby /docker-entrypoint.d/89-csr_attributes.rb