Tuesday, 2 December 2014

Testing a PR for Asterisk Puppet module on Docker

Just wanted to share what approach I'm following to test Pull Requests for the trulabs Asterisk Puppet module.
Run a docker container, choosing the base target distribution, e.g. one of:

docker run -i -t debian:wheezy /bin/bash
docker run -i -t ubuntu:precise /bin/bash
docker run -i -t ubuntu:trusty /bin/bash

Inside the Docker container, set up some preconditions:

apt-get update
apt-get install -y git
apt-get install -y puppet
apt-get install -y vim

Clone the git project:

mkdir -p git/trulabs
cd git/trulabs
git clone https://github.com/trulabs/puppet-asterisk.git
cd puppet-asterisk

Create a new branch:

git checkout -b PULL_REQUEST_BRANCH master

Checkout the project from which the Pull Request is created:

git pull https://github.com/CONTRIBUTOR/puppet-asterisk.git PULL_REQUEST_NAME

Build and install the Asterisk Puppet module built with this Pull Request changes:

puppet module build .
puppet module install pkg/trulabs-asterisk-VERSION.tar.gz --ignore-dependencies

(You typically need the concat module as a dependency:)

puppet module install puppetlabs-concat

Run puppet apply with the desired test manifest

puppet apply -v tests/TESTCASE.pp --modulepath modules/:/etc/puppet/modules --show_diff --noop

Et voilá. (Note that this will use the stock Puppet version - more to follow about safely configure Puppet 3.7 on any host).