This branch is intended as a portability fix. Some functionailty had
been inadvertently removed as unused, but testing revealed that it had a
purpose. Because the purpose was unclear, this commit restores the
functionality AND clarifies it in the script names and comments in
config_version.sh.
r10k generates a .r10k-deploy.json file since version 2.1.0 which was
released on October 28, 2015. New users of the control-repo are not
likely to have a so old version of r10k, so remove this dead code.
The appropriate ruby interpreter is determined by the config_version.sh
shell script which explicitely use it to start these ruby scripts.
Removing the execute bit ensure users will not run these script with the
wrong Ruby version.
- Fix shebang: `bash` is not always in `/bin/`, and since the script
does not have bashism, rely on `sh` which is always in `/bin/`;
- Use `/opt/puppetlabs/puppet/bin/ruby` if this file exist and is
executable, otherwise use `ruby` from $PATH;
- Use `code_manager_config_version.rb` if `.r10k-deploy.json` is found,
and `config_version.rb` in all other cases.
This is mainly a style and readability change.
Prior to this, on masters whose hostname is actually their FQDN, the
config_version script would show the entire FQDN. On nodes with really
longs FQDN's, it was not very nice to look at.
This takes the hostname of the master, splits it on dots (.) and takes
the first segment.
Now this: compile-master-02.int.lab.dmz.company-name.net-production-48fd18ab
Is this: compile-master-02-production-48fd18ab
Prior to this, the config_version.rb script (used for r10k) attempted to
use the system ruby to parse the script. This caused problems on Puppet
masters that don't have `ruby` in PATH.
This fixes that by hardcoding the puppet-agent's ruby in the shebang.
Prior to this, the config_version script just showed the commit ID of
the version of code being compiled. This commit includes the compiling
Puppet master's hostname and environment name in the config_version.
This is very useful for debugging when a Puppet master is failing and
you have multiple masters behind a load balancer.
The output of config_version now looks like this:
pupmaster01-production-ac9785273a10
Without this patch the control repository does not contain any scripts
to execute CI jobs for Puppet code deployment. This patch addresses the
problem by adding a Gitlab CI job configuration with three jobs defined
across two stages. The test stage executes first with a Syntax and a
Lint job executing in parallel. If an environment branch has been
pushed, one matching `developemnt`, `testing`, `production` or starting
with the prefix `playground`, the deploy stage is executed.
The deploy stage requires a Gitlab secret environment variable,
PUPPET_TOKEN. This environment variable is the puppet access token
configured with Code Manager.
The test stage runs the following syntax checks:
* yaml files (*.yml, *.yaml)
* json files (*.json)
* bash scripts (*.sh)
* ruby scripts (*.rb)
* puppet manifests (*.pp)
* erb files (*.erb)
The behavior of the checks are to check only files modified relative to
a base branch, defaulting to `production`. This avoids running syntax
checks against files which have not been modified by the merge request.
The check uses `git diff --name-status` to identify changed files across
multiple commits in a topic branch.
The lint checks rely on bundler and the Gemfile to install numerous lint
checks.
Gem libraries are installed in a per-job location in $HOME. This is an
intentional compromise between installing into a system GEM_PATH
element, which would create library conflicts with other jobs, and the
job workspace, which would cause gem libraries to be installed from the
network on each job invocation.
Prior to this commit, if you used windows bash git when you clone
down the repo these files would get incorrect permissions which
make them unexecutable.
After this commit, due to some windows bash git magic I don't
understand it appears that adding the shebang to the beginning of
the file causes windows bash git to change the permissions to
so the file is executable.
This resolves https://github.com/puppetlabs/control-repo/issues/40