This repository contains a building script for the vagrant-puppet project. Notably, this may include personal idiosyncrasies for VEuPathDB BRC Puppet development that other administrators may or may not find consistent with their workflow.
-
Clone this git repository under
vagrant-puppet/scratch
,
i.e.,vagrant-puppet/scratch/ebrc-buildvm
git clone git@github.com:krislamo/ebrc-buildvm.git
-
Symbolic link to
buildvm.sh
scriptcd ebrc-buildvm sudo ln -s "$(pwd)/buildvm.sh" /usr/local/bin/buildvm
-
Set the environment in
ebrc-buildvm/env/main
. Sample:# Vagrant settings + Puppet init override VAGRANTBOX=vagrant-puppet_default_X VAGRANTSNAP="Working SAVM" VAGRANTBRANCH=ksavm INITOVERRIDE=mytests # Symlinking for quick Puppet apply, i.e., buildvm -a ./vagrant-puppet declare -A MODULES MODULES[profiles]="/vagrant/scratch/puppet-profiles" # For ssh-keyscan on internal repos used for r10k deploy GIT_HOST=git.example.org GIT_PORT=22
-
Run
buildvm
against thevagrant-puppet
directorybuildvm -b ./vagrant-puppet
By default, the buildvm
script will apply any overrides (see INITOVERRIDE
) or syncing (see FROMSCRATCH
) and ensure the VAGRANTBRANCH
is checked out on puppet-control, puppet-hiera, and puppet-profiles. Additionally, for puppet-profiles, the script will ensure you're working with an up-to-date branch by rebasing on master.
Additional options:
-a
- Run puppet-apply against the virtual machine. Use alone for a quick puppet-apply for already symlinked Puppet modules.-b
- Builds the VM from a snapshot, deploying Puppet with r10k, symlinking select modules, and running puppet-apply. Sets options:-rdla
-d
- Deploy your Puppet environment using r10k-deploy inside the VM. Use with-l
to ensure module symlinks are restored after deploying.-e
- Set the ebrc-buildvm environment file, i.e.,ebrc-buildvm/env/$ENV
—defaults tomain
.-l
- Remove select modules defined as keys in theMODULES[]
array and replace them with symlinks to its value for a quick puppet-apply.-r
- Restores a VM to a previous snapshot before applying any other options.
Different ebrc-buildvm
environments allow you to switch which virtual machine, snapshot, and Puppet environment you're using for development. This is accomplished using bash shell variables set inside a file named after the environment. For example, the default environment named "main" is configured in the ./env/main
file.
To use other environments, pass the name of the environment to the -e
flag, i.e., buildvm -e otherenv
-
VAGRANTBOX
- The name of the virtual machine used for provisioning.- Find the name using:
vboxmanage list vms | awk '{print $1}'
- Find the name using:
-
VAGRANTSNAP
- The name of the virtual machine snapshot the build is based on.- Find the snapshot name using:
vboxmanage snapshot "$VAGRANTBOX" list | grep Name
- Find the snapshot name using:
-
VAGRANTBRANCH
- The name of the puppet environment and branch names used for git checkouts.- The following repositories are assumed to have this branch name:
puppet-control
,puppet-hiera
,puppet-profiles
. Additionally, the Puppet r10k environment used for provisioning is expected to have this shared name.
- The following repositories are assumed to have this branch name:
-
FROMSCRATCH
(OPTIONAL) - A directory to copy data from into thevagrant-puppet/scratch
directory- If this option is set, the script will rsync data from the specified location into the vagrant-puppet scratch directory. This is useful for saving disk space (via hard links) for multiple virtual machines and centralizing Puppet code editing.
-
INITOVERRIDE
(OPTIONAL) - A subdirectory atpuppet-control/manfiests/$INITOVERRIDE/
to move init.pp files- This setup requires a slight modification to
puppet-control/manifests/site.pp
to include a subdirectory with ainit.pp
file.
e.g.,node default { include mytests }
- In the example above,
INITOVERRIDE=mytests
- This allows for a centralized directory of multiple
init.pp
files for different virtual machines. The option will removepuppet-control/manifests/$INITOVERRIDE/init.pp
and replace it withpuppet-control/manifests/$INITOVERRIDE/$VAGRANTENV-init.txt
automatically before provisioning. - Do not place data into the
$INITOVERRIDE/init.pp
file directly with this set.
- This setup requires a slight modification to
Copyright 2021 Kris Lamoureux
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.