Skip to content

Commit

Permalink
Merge pull request #60 from tuxmea/csr_attributes
Browse files Browse the repository at this point in the history
allow setting csr attributes
  • Loading branch information
bastelfreak authored Jan 31, 2024
2 parents bc30a2f + 0553b30 commit a8129e7
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 1 deletion.
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

0 comments on commit a8129e7

Please sign in to comment.