Closed raphink closed 6 years ago
The goal is to be able to run puppet generate types --environment <env>
as a postrun command (as per https://github.com/puppetlabs/r10k/issues/693), so using the -branch
parameter should do if I understood it properly.
That depends if you even call g10k with the -branch
CLI parameter.
If you just use the -config
paramter, like I'm currently doing:
./g10k -config tests/TestConfigPrefix.yaml
Then $environment
will be replaced with an empty string.
I would call it with -branch
in a hook. But then, when -branch
is not passed, it should actually launch the postrun command for each environment if it matches $environment
. That's how I implemented it in https://github.com/puppetlabs/r10k/pull/836
Ok, i'll merge it for now, so that it works for you with the -branch
CLI parameter.
I don't really agree on always executing the postrun command multiple times for each modified environment. This would be a problem with user, who use the postrun command for something else that should only happen one, like restarting their monitoring server or something.
Then it would be better to just call the postrun command and append all modified environments to it. Then a simple bash wrapper script, like
#! /bin/bash
if [ $# -eq 0 ]; then
echo "Nothing to do"
exit 0
fi
for modified_environment in "$@"; do
echo puppet generate types --environment "$modified_environment"
done
would also work:
$ bash postrun.sh /var/data/puppet_sync/g10k/foobar/foobar_dev/ /var/data/puppet_sync/g10k/foobar/foobar_master/
puppet generate types --environment /var/data/puppet_sync/g10k/foobar/foobar_dev/
puppet generate types --environment /var/data/puppet_sync/g10k/foobar/foobar_master/
Sounds good to you?
That's a good point indeed. I could also implement it this way in r10k actually, passing a list of environments to the script, although that will mean writing a wrapper for the generate types call.
Merged. I did create #112 to append all modified environments to the postrun command
Great stuff.
I'll extend the test to check if the replacement in the postrun command was really successful later.
You know that
branchName
(https://github.com/xorpaul/g10k/pull/111/files#diff-0db6c4cba252a5da5bf2b032094e863dR279) is only the-branch
CLI parameter, yes?Is that what you want? Is there an equivalent feature in r10k?
I'm thinking about also adding a variable with all the environment directories that need to be synced.
Should add a slice with
["/var/data/puppet_sync/g10k/foobar/foobar_dev/", "/var/data/puppet_sync/g10k/foobar/foobar_master/"]
to the postrun command.What do think about that?