Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow setting csr attributes #60

Merged
merged 1 commit into from
Jan 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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<br><br> Defaults to `true` |
| **ENVIRONMENTPATH** | Set an environmentpath<br><br> Defaults to `/etc/puppetlabs/code/environments` |
| **HIERACONFIG** | Set a hiera_config entry in puppet.conf file<br><br> 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" } }'<br><br> Defaults to empty JSON object '{}'<br> Please note that within a compose file, you must quote the whole line<br> - 'CSR_ATTRIBUTES={ ...}' |

## Initialization Scripts

Expand Down
3 changes: 2 additions & 1 deletion puppetserver/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
15 changes: 15 additions & 0 deletions puppetserver/docker-entrypoint.d/89-csr_attributes.rb
Original file line number Diff line number Diff line change
@@ -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
3 changes: 3 additions & 0 deletions puppetserver/docker-entrypoint.d/89-csr_attributes.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/bash
echo $CSR_ATTRIBUTES
/opt/puppetlabs/puppet/bin/ruby /docker-entrypoint.d/89-csr_attributes.rb