Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
nodes.pp
modules/*
.vagrant
repository/yum/*
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ should be good to clone this repo and go:
If you want a CentOS base box to work from, I highly recommend the boxes
published by Jan Vansteenkiste: http://packages.vstone.eu/vagrant-boxes/

The Vagrantfile is a symlink to either Vagrantfile.precise64 or Vagrantfile.centos63.

Initial Startup
---------------

Expand Down Expand Up @@ -101,7 +103,7 @@ be picked up immediately.
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
Check Your Handywork

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Heh - the original was correct here as well. You picked an "archaic variant" to change it to. This I find amusing! :)

--------------------

To log on to the virtual machines and see the result of your applied Puppet
Expand All @@ -116,6 +118,11 @@ the agent daemon, you can easily force a manual run:

[vagrant@client1 ~]$ sudo puppet agent --test

Package Repositories
--------------------

A local YUM repo `sandbox` is configured on the puppet server. Copy RPM files into `repository/yum` and then the next run of puppet will refresh the yum repository ... if the puppet VM is already up you can run `vagrant provision puppet` to refresh it.

License
=======

Expand Down
39 changes: 0 additions & 39 deletions Vagrantfile

This file was deleted.

1 change: 1 addition & 0 deletions Vagrantfile
39 changes: 39 additions & 0 deletions Vagrantfile.centos63
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

domain = 'example.com'

puppet_nodes = [
{:hostname => 'puppet', :ip => '172.16.32.10', :box => 'centos63', :fwdhost => 8140, :fwdguest => 8140, :ram => 512},
{:hostname => 'client1', :ip => '172.16.32.11', :box => 'centos63'},
{:hostname => 'client2', :ip => '172.16.32.12', :box => 'centos63'},
]

Vagrant.configure("2") do |config|
puppet_nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.box = node[:box]
node_config.vm.box_url = 'http://files.vagrantup.com/' + node_config.vm.box + '.box'
node_config.vm.hostname = node[:hostname] + '.' + domain
node_config.vm.network :private_network, ip: node[:ip]

if node[:fwdhost]
node_config.vm.network :forwarded_port, guest: node[:fwdguest], host: node[:fwdhost]
end

memory = node[:ram] ? node[:ram] : 256;
node_config.vm.provider :virtualbox do |vb|
vb.customize [
'modifyvm', :id,
'--name', node[:hostname],
'--memory', memory.to_s
]
end

node_config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'provision/manifests'
puppet.module_path = 'provision/modules'
end
end
end
end
39 changes: 39 additions & 0 deletions Vagrantfile.precise64
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# -*- mode: ruby -*-
# vi: set ft=ruby :

domain = 'example.com'

puppet_nodes = [
{:hostname => 'puppet', :ip => '172.16.32.10', :box => 'precise64', :fwdhost => 8140, :fwdguest => 8140, :ram => 512},
{:hostname => 'client1', :ip => '172.16.32.11', :box => 'precise64'},
{:hostname => 'client2', :ip => '172.16.32.12', :box => 'precise64'},
]

Vagrant.configure("2") do |config|
puppet_nodes.each do |node|
config.vm.define node[:hostname] do |node_config|
node_config.vm.box = node[:box]
node_config.vm.box_url = 'http://files.vagrantup.com/' + node_config.vm.box + '.box'
node_config.vm.hostname = node[:hostname] + '.' + domain
node_config.vm.network :private_network, ip: node[:ip]

if node[:fwdhost]
node_config.vm.network :forwarded_port, guest: node[:fwdguest], host: node[:fwdhost]
end

memory = node[:ram] ? node[:ram] : 256;
node_config.vm.provider :virtualbox do |vb|
vb.customize [
'modifyvm', :id,
'--name', node[:hostname],
'--memory', memory.to_s
]
end

node_config.vm.provision :puppet do |puppet|
puppet.manifests_path = 'provision/manifests'
puppet.module_path = 'provision/modules'
end
end
end
end
3 changes: 3 additions & 0 deletions provision/manifests/default.pp
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@

if $hostname == 'puppet' {
class { 'puppet::server': }
class { 'repository::server': }
} else {
class { 'repository::client': stage => 'pre' }
}
9 changes: 9 additions & 0 deletions provision/modules/repository/files/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Sandbox YUM Repo</title>
</head>
<body>
Sandbox YUM Repo
</body>
</html>

5 changes: 5 additions & 0 deletions provision/modules/repository/files/sandbox.repo
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[sandbox]
name=sandbox
baseurl=http://puppet/
enabled=1
gpgcheck=0
7 changes: 7 additions & 0 deletions provision/modules/repository/files/yum-repo.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /vagrant/repository/yum/
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>
13 changes: 13 additions & 0 deletions provision/modules/repository/manifests/client-yum.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
class repository::client-yum {

file { 'sandbox.repo':
ensure => present,
path => '/etc/yum.repos.d/sandbox.repo',
owner => root,
group => root,
mode => '0644',
replace => true,
source => 'puppet:///modules/repository/sandbox.repo',
}

}
17 changes: 17 additions & 0 deletions provision/modules/repository/manifests/client.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# class repository::client

class repository::client {

case $::osfamily {
'redhat': {
class { 'repository::client-yum': }
}
## 'debian': {
## class { 'repository::client-apt': }
## }
default: {
#fail("Module '${module_name}' is not currently supported by Puppet Sandbox on ${::operatingsystem}")
}
}

}
1 change: 1 addition & 0 deletions provision/modules/repository/manifests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class repository {}
58 changes: 58 additions & 0 deletions provision/modules/repository/manifests/server-yum.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
# == Class: repository::server::yum
#
#
class repository::server-yum {

# Gimme some apache!
package { 'httpd':
ensure => 'present';
}

package { 'createrepo':
ensure => 'present',
notify => Exec["yum_createrepo"],
}

file { 'yum-repo.conf':
ensure => present,
path => '/etc/httpd/conf.d/yum-repo.conf',
owner => root,
group => root,
mode => '0644',
replace => true,
source => 'puppet:///modules/repository/yum-repo.conf',
}


file { '/vagrant/repository/yum':
path => '/vagrant/repository/yum',
ensure => directory,
owner => root,
group => root,
mode => '0644',
recurse => true,
notify => Exec['yum_createrepo'],
}

file { 'index.html':
ensure => present,
path => '/vagrant/repository/yum/index.html',
owner => root,
group => root,
mode => '0644',
replace => true,
source => 'puppet:///modules/repository/index.html',
}

exec { 'yum_createrepo':
command => '/usr/bin/createrepo /vagrant/repository/yum',
refreshonly => true,
}

service { "httpd":
ensure => "running",
subscribe => File["yum-repo.conf"],
}

}

19 changes: 19 additions & 0 deletions provision/modules/repository/manifests/server.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# class repository::server

class repository::server {

#include repository::server-yum
#include repository::server-apt

case $::osfamily {
'redhat': {
class { 'repository::server-yum': }
}
## 'debian': {
## class { 'repository::server::apt': }
## }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like how you included these to make the debian integration more straightforward in the future. 👍

default: {
#fail("Module '${module_name}' is not currently supported by Puppet Sandbox on ${::operatingsystem}")
}
}
}
9 changes: 9 additions & 0 deletions provision/modules/repository/templates/index.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<html>
<head>
<title>Sandbox YUM Repo</title>
</head>
<body>
Sandbox YUM Repo
</body>
</html>

7 changes: 7 additions & 0 deletions provision/modules/repository/templates/yum-repo.conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot /vagrant/repository/yum/
ServerName dummy-host.example.com
ErrorLog logs/dummy-host.example.com-error_log
CustomLog logs/dummy-host.example.com-access_log common
</VirtualHost>