Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial clone of puppet-sandbox repository
- Loading branch information
0 parents
commit 7ff9348
Showing
21 changed files
with
650 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
nodes.pp | ||
modules/* | ||
.vagrant |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Copyright (c) 2012, Aaron Bull Schaefer | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining | ||
a copy of this software and associated documentation files (the | ||
"Software"), to deal in the Software without restriction, including | ||
without limitation the rights to use, copy, modify, merge, publish, | ||
distribute, sublicense, and/or sell copies of the Software, and to | ||
permit persons to whom the Software is furnished to do so, subject to | ||
the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be | ||
included in all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
Description | ||
=========== | ||
|
||
Puppet Sandbox is a multi-VM [Vagrant](http://vagrantup.com/)-based Puppet | ||
development environment used for creating and testing new modules outside | ||
of your production environment. It is prefered over the upstream [Learning | ||
Puppet VM](http://info.puppetlabs.com/download-learning-puppet-VM.html) as | ||
it gives you more flexibility and allows you to use your own local editing | ||
environment and tools. | ||
|
||
Puppet Sandbox will set up three separate virtual machines: | ||
|
||
* _puppet.example.com_ - the Puppet master server | ||
* _client1.example.com_ - the first Puppet client machine | ||
* _client2.example.com_ - the second Puppet client machine | ||
|
||
These VMs can be used in conjunction to segregate and test your modules | ||
based on node roles, Puppet environments, etc. You can even test modules | ||
on different Linux distributions or release versions to better match your | ||
production infrastructure. | ||
|
||
**Check out the [Puppet Sandbox Demonstration](http://vimeo.com/elasticdog/puppet-sandbox-demo) | ||
screencast for a brief overview of the project.** | ||
|
||
Requirements | ||
============ | ||
|
||
To use Puppet Sandbox, you must have the following items installed and working: | ||
|
||
* [VirtualBox](https://www.virtualbox.org/) | ||
* [Vagrant](http://vagrantup.com/) | ||
|
||
Puppet Sandbox has been designed for and tested with Vagrant base boxes running: | ||
|
||
* CentOS 5.7 | ||
* Ubuntu 10.04 - Lucid Lynx | ||
|
||
...although it may work just fine with other distributions/versions. | ||
|
||
Usage | ||
===== | ||
|
||
Make sure you have a compatible Vagrant base box (if you don't have one | ||
already, it will download a 64-bit CentOS 5.7 box for you), and then you | ||
should be good to clone this repo and go: | ||
|
||
$ vagrant box list | ||
centos57 | ||
$ git clone git://github.com/elasticdog/puppet-sandbox.git | ||
$ cd puppet-sandbox/ | ||
|
||
Initial Startup | ||
--------------- | ||
|
||
To bring up the Puppet Sandbox environment, issue the following command: | ||
|
||
$ vagrant up | ||
|
||
The following tasks will be handled automatically: | ||
|
||
1. The Puppet server daemon will be installed and enabled on the master | ||
machine. | ||
2. The Puppet client agent will be installed and enabled on all three machines. | ||
3. A host-only network will be set up with all machines knowing how to | ||
communicate with each other. | ||
4. All client certificate requests will be automatically signed by the master | ||
server. | ||
5. The master server will utilize the `nodes.pp` file and `modules/` directory | ||
that exist **outside of the VMs** (in your puppet-sandbox Git working | ||
directory) by utilizing VirtualBox's shared folder feature. | ||
|
||
All of this is handled using Vagrant's provisioning capabilities and is | ||
controlled by the manifests under the `provision/` directory. In theory, you | ||
should never have to touch any of that code directly unless you're working to | ||
improve Puppet Sandbox. | ||
|
||
If you wish to change the domain name of the VMs (it defaults to | ||
_example.com_), edit the "domain" variable at the top of `Vagrantfile` and | ||
reload the machines: | ||
|
||
$ vim Vagrantfile | ||
$ vagrant reload | ||
|
||
Developing New Modules | ||
---------------------- | ||
|
||
To start developing a new Puppet module, just create the standard module | ||
structure under `modules/` in your puppet-sandbox Git working directory (an | ||
example "helloworld" module should exist there already). This directory is | ||
automatically in the Puppet master server's _modulepath_, and any changes will | ||
be picked up immediately. | ||
|
||
$ mkdir -p modules/users/manifests | ||
$ vim modules/users/manifests/init.pp | ||
|
||
To have your module actually applied to one or more of the nodes, edit the | ||
`nodes.pp` file and include your classes...that's it! | ||
|
||
Check Your Handiwork | ||
-------------------- | ||
|
||
To log on to the virtual machines and see the result of your applied Puppet | ||
modules, just use standard [Vagrant Multi-VM | ||
Environment](http://vagrantup.com/docs/multivm.html) commands, and provide the | ||
proper VM name (`master`, `client1`, or `client2`): | ||
|
||
$ vagrant ssh client1 | ||
|
||
If you don't want to wait for the standard 30-minutes between Puppet runs by | ||
the agent daemon, you can easily force a manual run: | ||
|
||
[vagrant@client1 ~]$ sudo puppet agent --test | ||
|
||
License | ||
======= | ||
|
||
Puppet Sanbox is provided under the terms of [The MIT | ||
License](http://www.opensource.org/licenses/MIT). | ||
|
||
Copyright © 2012, [Aaron Bull Schaefer](mailto:aaron@elasticdog.com). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
* Support CentOS 6 and Arch Linux | ||
* Add an easy way to specify desired Puppet version | ||
* Make hosts file dynamic based on what is defined in Vagrantfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
# -*- mode: ruby -*- | ||
# vi: set ft=ruby : | ||
|
||
domain = 'example.com' | ||
|
||
Vagrant::Config.run do |config| | ||
config.vm.define :master do |master_config| | ||
master_config.vm.box = 'centos57' | ||
master_config.vm.box_url = 'http://yum.mnxsolutions.com/vagrant/centos57_64.box' | ||
master_config.vm.host_name = "puppet.#{domain}" | ||
master_config.vm.network :hostonly, '172.16.32.10' | ||
|
||
master_config.vm.provision :puppet do |puppet| | ||
puppet.manifests_path = 'provision/manifests' | ||
puppet.module_path = 'provision/modules' | ||
end | ||
end | ||
|
||
config.vm.define :client1 do |client_config| | ||
client_config.vm.box = 'centos57' | ||
client_config.vm.box_url = 'http://yum.mnxsolutions.com/vagrant/centos57_64.box' | ||
client_config.vm.host_name = "client1.#{domain}" | ||
client_config.vm.network :hostonly, '172.16.32.11' | ||
|
||
client_config.vm.provision :puppet do |puppet| | ||
puppet.manifests_path = 'provision/manifests' | ||
puppet.module_path = 'provision/modules' | ||
end | ||
end | ||
|
||
config.vm.define :client2 do |client_config| | ||
client_config.vm.box = 'lucid32' | ||
client_config.vm.box_url = 'http://yum.mnxsolutions.com/vagrant/centos57_64.box' | ||
client_config.vm.host_name = "client2.#{domain}" | ||
client_config.vm.network :hostonly, '172.16.32.12' | ||
|
||
client_config.vm.provision :puppet do |puppet| | ||
puppet.manifests_path = 'provision/manifests' | ||
puppet.module_path = 'provision/modules' | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# == Class: helloworld | ||
# | ||
# This class is a bare bones example to ensure puppet master/clients are | ||
# talking to each other. | ||
# | ||
# === Parameters | ||
# | ||
# === Actions | ||
# | ||
# === Requires | ||
# | ||
# === Sample Usage | ||
# | ||
# class { 'helloworld': } | ||
# | ||
class helloworld { | ||
|
||
file { '/tmp/hello': | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0666', | ||
content => "world\n", | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
# | ||
# site.pp - defines defaults for vagrant provisioning | ||
# | ||
|
||
# use run stages for minor vagrant environment fixes | ||
stage { 'pre': before => Stage['main'] } | ||
class { 'mirrors': stage => 'pre' } | ||
class { 'vagrant': stage => 'pre' } | ||
|
||
class { 'puppet': } | ||
class { 'networking': } | ||
|
||
if $hostname == 'puppet' { | ||
class { 'puppet::server': } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# == Class: mirrors::apt | ||
# | ||
# This class installs the Puppet Labs APT repository. | ||
# | ||
# === Parameters | ||
# | ||
# === Actions | ||
# | ||
# - Install puppetlabs repository | ||
# - Perform initial sync to update package database | ||
# | ||
# === Requires | ||
# | ||
# === Sample Usage | ||
# | ||
# class { 'mirrors::apt': } | ||
# | ||
class mirrors::apt { | ||
|
||
$puppetlabs_key = '4BD6EC30' | ||
|
||
exec { 'apt_key_puppetlabs': | ||
path => '/bin:/usr/bin', | ||
unless => "/usr/bin/apt-key list | /bin/grep -q '${puppetlabs_key}'", | ||
command => "apt-key adv --keyserver 'pgp.mit.edu' --recv-keys '${puppetlabs_key}'", | ||
before => File[ 'puppetlabs.list' ], | ||
} | ||
|
||
file { 'puppetlabs.list': | ||
ensure => present, | ||
path => '/etc/apt/sources.list.d/puppetlabs.list', | ||
owner => root, | ||
group => root, | ||
mode => '0644', | ||
content => template('mirrors/puppetlabs.list.erb'), | ||
} | ||
|
||
exec { 'apt_update': | ||
command => '/usr/bin/apt-get update', | ||
subscribe => File[ 'puppetlabs.list' ], | ||
refreshonly => true, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# == Class: mirrors | ||
# | ||
# This class loads the relevant distribution-specific package repository | ||
# manifests and would be the place to configure any other custom mirrors you | ||
# may want. | ||
# | ||
# === Parameters | ||
# | ||
# === Actions | ||
# | ||
# === Requires | ||
# | ||
# === Sample Usage | ||
# | ||
# class { 'mirrors': } | ||
# | ||
class mirrors { | ||
|
||
case $::operatingsystem { | ||
'centos', 'fedora', 'redhat', 'scientific': { | ||
class { 'mirrors::yum': } | ||
} | ||
'debian', 'ubuntu': { | ||
class { 'mirrors::apt': } | ||
} | ||
default: { | ||
fail("Module '${module_name}' is not currently supported by Puppet Sandbox on ${::operatingsystem}") | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
# == Class: mirrors::yum | ||
# | ||
# This class installs the Puppet Labs YUM repository. | ||
# | ||
# === Parameters | ||
# | ||
# === Actions | ||
# | ||
# - Install puppetlabs repository | ||
# - Perform initial sync to update package database | ||
# | ||
# === Requires | ||
# | ||
# === Sample Usage | ||
# | ||
# class { 'mirrors::yum': } | ||
# | ||
class mirrors::yum { | ||
|
||
# can't rely on $lsbmajdistrelease being available on CentOS, and lsb's | ||
# dependencies are huge, so don't force installation of the package | ||
$os_release_major_version = regsubst($operatingsystemrelease, '^(\d+).*$', '\1') | ||
|
||
file { 'puppetlabs.repo': | ||
ensure => present, | ||
path => '/etc/yum.repos.d/puppetlabs.repo', | ||
owner => root, | ||
group => root, | ||
mode => '0644', | ||
content => template('mirrors/puppetlabs.repo.erb'), | ||
} | ||
|
||
exec { 'yum_makecache': | ||
command => '/usr/bin/yum makecache', | ||
subscribe => File[ 'puppetlabs.repo' ], | ||
refreshonly => true, | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
deb http://apt.puppetlabs.com <%= lsbdistcodename %> main | ||
deb-src http://apt.puppetlabs.com <%= lsbdistcodename %> main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
[puppetlabs-products] | ||
name=Puppet Labs Products <%= os_release_major_version %> - $basearch | ||
baseurl=http://yum.puppetlabs.com/el/<%= os_release_major_version %>/products/$basearch | ||
gpgkey=http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs | ||
enabled=1 | ||
gpgcheck=1 | ||
|
||
[puppetlabs-deps] | ||
name=Puppet Labs Dependencies <%= os_release_major_version %> - $basearch | ||
baseurl=http://yum.puppetlabs.com/el/<%= os_release_major_version %>/dependencies/$basearch | ||
gpgkey=http://yum.puppetlabs.com/RPM-GPG-KEY-puppetlabs | ||
enabled=1 | ||
gpgcheck=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# == Class: networking | ||
# | ||
# This class configures the hosts file to allow communication between the | ||
# puppet master and puppet clients using the VirtualBox host-only network. | ||
# | ||
# === Parameters | ||
# | ||
# === Actions | ||
# | ||
# - Install custom hosts template | ||
# | ||
# === Requires | ||
# | ||
# === Sample Usage | ||
# | ||
# class { 'networking': } | ||
# | ||
class networking { | ||
|
||
file { '/etc/hosts': | ||
owner => 'root', | ||
group => 'root', | ||
mode => '0644', | ||
content => template('networking/hosts.erb'), | ||
} | ||
|
||
} |
Oops, something went wrong.