Closed kasimon closed 6 years ago
Hmm, I'm doing that in my g10k wrapper script on a central server that then syncs all Puppet environments to the actual Puppetservers.
If g10k should do this the it needs to first symlink all modified/new Puppet environment directories to your g10k user's home /home/<g10k_users>/.puppet/etc/code/environments/
and then do the actual puppet generate types --environment <puppetenv>
command.
Does that sound good to you?
In my case that would not be nessecary as I run g10k directly as root on my puppet masters, so it would literally be 'call puppet generate types'. But maybe a simpler option would be a post-env-update hook that runs an arbitrary command after updating an environment.
Now with https://github.com/xorpaul/g10k/releases/tag/v0.5.2 you can either execute an arbitrary command after the g10k run via
postrun: ['/usr/bin/touch', '-f', '/tmp/g10kfoobar']
in your g10k config file, like here tests/TestConfigPostrunCommand.yaml
to trigger your puppet generate types
command.
Or if you use the -branch
CLI command you can add $environment
to your postrun command to add the branch name to the command.
postrun: ['puppet', 'generate', 'types', '--environment', '$environment']
or wait until I'm done with #112 to append all modified Puppet environment directories to the postrun command and then you can use a simple wrapper script and modify it as needed, see https://github.com/xorpaul/g10k/issues/112#issue-353808371
Awesome!
Starting with v0.5.3 you can use a simple wrapper script to call your puppet generate types
, like so:
postrun: ['puppet_generate_wrapper.sh', '$modifiedenvs']
Which then gets all modified Puppet environment names as a parameter.
#! /bin/bash
LOGFILE="/tmp/postrun.log"
if [ $# -eq 0 ]; then
echo "Nothing to do" | tee -a ${LOGFILE}
exit 0
fi
for argument in "$@"; do
/opt/puppetlabs/bin/puppet generate types --environment ${argument}" | tee -a ${LOGFILE}
done
See https://github.com/xorpaul/g10k/issues/112#issuecomment-419442969 for more details.
Fantastic, thank you!
It would be very comfortable if there was an option to run 'puppet generate types' (https://puppet.com/docs/puppet/5.3/environment_isolation.html#generate-types) on every updated environment.