voxpupuli/container-puppetserver

Scripts should abort after abnormal exits of subcommands

Closed this issue · 1 comments

Hi,

the shell scripts coming with container-puppetserver should be set to either detect abnormal exits (return value != 0) or to abort if a subcommand fails.

I just was debugging a bug I made myself in a /docker-custom-entrypoint.d/. I've set an entry in an illegal section with something like

puppet config set --section example something yes

which is not just ignored, commands like

puppet config print certname

then do fail with
Error: Could not parse /etc/puppetlabs/puppet/puppet.conf: Illegal section 'example' in config file at (file: /etc/puppetlabs/puppet/puppet.conf, line: 23). The only valid puppet.conf sections are: [main, server, master, agent, user]. Please use the directory environments feature to specify environments. (See https://puppet.com/docs/puppet/latest/environments_about.html)

Problem:

The docker container still came up, I was just wondering why it behaved strange and ignored several environment settings as the DNS_ALT_NAMES.

As far as I can see, e.g. the script /docker-entrypoint.d/70-set-dns-alt-names.sh uses a command like

certname=$(puppet config print certname)

but seems to ignore if the subcommand fails, and still runs through, making the server come up, but with wrong parameters.

Instead, the container should abort, if something is wrong with the configuration, instead of running with bad or incomplete configurations. Maybe just a set -e would help.

regards

thx for the hint. i added set -e to all scripts :)