Skip to content

Instantly share code, notes, and snippets.

@timhughes
Last active December 31, 2015 08:59
Show Gist options
  • Save timhughes/7964388 to your computer and use it in GitHub Desktop.
Save timhughes/7964388 to your computer and use it in GitHub Desktop.
Puppet testing environment
Puppet testing
==============
http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
TODO: we probably need the puppet gem installed in the rvm for any of this to work
Initial install of RVM::
\curl -sSL https://get.rvm.io | bash -s -- --ignore-dotfiles
Add the sourcing of RVM to bash::
########################
# Ruby configuration
########################
# Ruby Version Manager
# https://rvm.io/
#
# Add RVM to PATH for scripting
PATH=$PATH:$HOME/.rvm/bin
# Load RVM into a shell session *as a function*
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
# Add RVM to bash prompt
PS1="\$(~/.rvm/bin/rvm-prompt)$PS1"
####### end ruby #######
Install Ruby version::
rvm install 1.8.7
The previous command will set your default ruby. To change to system ruby use::
rvm system
TODO: How do I set the default ruby to bet systems ruby.
rvm reset # doesnt work !!!!
If you dont want install the documentation for every package add the following to `~/.gemrc`:
install: --no-ri --no-rdoc
update: --no-ri --no-rdoc
Install the required gems::
gem install puppet puppetlabs_spec_helper puppet-lint rcov
Create a working directory::
mkdir ~/puppet_modules
cd ~/puppet_modules
Puppet module name for puppetforge::
MYNAME=$(getent passwd `whoami` | cut -d ':' -f 5|sed 's/ //g;s/\(.*\)/\L\1/')
MODULE=repos
puppet module generate $MYNAME-$MODULE
cd $MYNAME-$MODULE
Create gitignore file::
cat <<EOF > .gitignore
pkg/
Gemfile.lock
.rspec_system/
.*.sw*
/spec/fixtures/.librarian
/spec/fixtures/.tmp
/spec/fixtures/Puppetfile.lock
/spec/fixtures/modules
/spec/fixtures/vendor
EOF
Create gitignore file::
cat <<EOF > .fixtures.yml
fixtures:
symlinks:
$MODULE: "#{source_dir}"
EOF
Create gitignore file::
cat <<EOF > Rakefile
require 'puppetlabs_spec_helper/rake_tasks'
EOF
Create spec_helper file::
cat <<EOF > spec/spec_helper.rb
require 'puppetlabs_spec_helper/module_spec_helper'
EOF
Create modules default spec file::
mkdir spec/classes/
cat <<EOF> spec/classes/$MODULE_spec.rb
require 'spec_helper'
describe '$MODULE', :type => 'class' do
# Add your module tests here
end
EOF
Create Gemfile file::
cat <<EOF> Gemfile
source "https://rubygems.org"
gem "puppet"
gem "puppetlabs_spec_helper"
gem "puppet-lint"
gem "rcov"
EOF
Live Testing with Docker
------------------------
- https://github.com/jpetazzo/pipework/blob/master/pipework
- http://www.slideshare.net/PuppetLabs/docker-puppetcamp-london
- http://karlgrz.com/testing-salt-states-rapidly-with-docker/
cat<<EOF >Dockerfile
# Puppet master
#
FROM centos
MAINTAINER Tim Hughes <thughes@thegoldfish.org>
RUN urlgrabber https://gist.github.com/timhughes/7999298/raw/372313377ae2e6c9c75b53e271ca7406f33058d0/puppet-master.sh
RUN bash puppet-master.sh
RUN yum install -y supervisor
RUN yum -y update
EXPOSE 8140
CMD ['/etc/init.d/httpd', '-D', 'FOREGROUND']
EOF
docker build -t puppet_master - < Dockerfile
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment