Skip to content

Commit

Permalink
First commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Apress committed Oct 17, 2016
0 parents commit a416b7a
Show file tree
Hide file tree
Showing 31 changed files with 685 additions and 0 deletions.
Binary file added 9781430260400.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions LICENSE.txt
@@ -0,0 +1,27 @@
Freeware License, some rights reserved

Copyright (c) 2013 Spencer Krum, William Van Hevelingen, Ben Kero, James Turnbull, and Jeffrey McCune

Permission is hereby granted, free of charge, to anyone obtaining a copy
of this software and associated documentation files (the "Software"),
to work with the Software within the limits of freeware distribution and fair use.
This includes the rights to use, copy, and modify the Software for personal use.
Users are also allowed and encouraged to submit corrections and modifications
to the Software for the benefit of other users.

It is not allowed to reuse, modify, or redistribute the Software for
commercial use in any way, or for a user�s educational materials such as books
or blog articles without prior permission from the copyright holder.

The above copyright notice and this permission notice need to 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 OR APRESS 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.


15 changes: 15 additions & 0 deletions README.md
@@ -0,0 +1,15 @@
#Apress Source Code

This repository accompanies [*Pro Puppet*](http://www.apress.com/9781430260400) by Spencer Krum, William Van Hevelingen, Ben Kero, James Turnbull, and Jeffrey McCune (Apress, 2013).

![Cover image](9781430260400.jpg)

Download the files as a zip using the green button, or clone the repository to your machine using Git.

##Releases

Release v1.0 corresponds to the code in the published book, without corrections or updates.

##Contributions

See the file Contributing.md for more information on how you can contribute to this repository.
14 changes: 14 additions & 0 deletions contributing.md
@@ -0,0 +1,14 @@
# Contributing to Apress Source Code

Copyright for Apress source code belongs to the author(s). However, under fair use you are encouraged to fork and contribute minor corrections and updates for the benefit of the author(s) and other readers.

## How to Contribute

1. Make sure you have a GitHub account.
2. Fork the repository for the relevant book.
3. Create a new branch on which to make your change, e.g.
`git checkout -b my_code_contribution`
4. Commit your change. Include a commit message describing the correction. Please note that if your commit message is not clear, the correction will not be accepted.
5. Submit a pull request.

Thank you for your contribution!
35 changes: 35 additions & 0 deletions source-code-master/ch01/bootstrap.sh
@@ -0,0 +1,35 @@
#!/bin/bash
# short script to install puppet on a few different system

#Debian Squeeze:

tempdir=/tmp/pro-puppet

pushd $tempdir

wget http://apt.puppetlabs.com/puppetlabs-release-squeeze.deb
dpkg -i puppetlabs-release-squeeze.deb
apt-get update

#Ubuntu Precise:

wget http://apt.puppetlabs.com/puppetlabs-release-precise.deb
dpkg -i puppetlabs-release-precise.deb
apt-get update


rpm -Uvh http://dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

#Enterprise Linux 6:

rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
vh http://yum.puppetlabs.com/el/5/products/i386/puppetlabs-release-5-7.noarch.rpm

Enterprise Linux 6:

rpm -ivh http://yum.puppetlabs.com/el/6/products/i386/puppetlabs-release-6-7.noarch.rpm

popd

rm -fr $tempdir

28 changes: 28 additions & 0 deletions source-code-master/ch01/site.pp
@@ -0,0 +1,28 @@


node ' node1.pro-puppet.com ' {
package { 'vim':
ensure => present,
}
}

node /^www\d+\.pro-puppet\.com/
{
...
}


node 'node1.pro-puppet.com' {
include sudo
}

node /node1/ {
include ::sudo
}
node /node2/ {
class { '::sudo':
users => ['tom', 'jerry'],
}
}


21 changes: 21 additions & 0 deletions source-code-master/ch01/sudo/manifests/init.pp
@@ -0,0 +1,21 @@
class sudo {

package { 'sudo':
ensure => present,
}

if $::osfamily == 'Debian' {
package { 'sudo-ldap':
ensure => present,
require => Package['sudo'],
}
}

file { '/etc/sudoers':
owner => 'root',
group => 'root',
mode => '0440',
source => "puppet://$::server/modules/sudo/etc/sudoers",
require => Package['sudo'],
}
}
Empty file.
5 changes: 5 additions & 0 deletions source-code-master/ch02/apache/manifests/install.pp
@@ -0,0 +1,5 @@
class apache::install {
package { [ 'apache2' ]:
ensure => present,
}
}
9 changes: 9 additions & 0 deletions source-code-master/ch02/apache/manifests/service.pp
@@ -0,0 +1,9 @@
class apache::service {
service { "apache2":
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class['apache::install'],
}
}
18 changes: 18 additions & 0 deletions source-code-master/ch02/apache/manifests/vhost.pp
@@ -0,0 +1,18 @@
define apache::vhost(
$docroot,
$port,
$priority,
$ssl=true,
$serveraliases = '',
$template='apache/vhost.conf.erb',
){
include apache
file {"/etc/apache2/sites-enabled/${priority}-${name}":
content => template($template),
owner => 'root',
group => 'root',
mode => '0640',
require => Class['apache::install'],
notify => Class['apache::service'],
}
}
32 changes: 32 additions & 0 deletions source-code-master/ch02/apache/template/vhost.erb
@@ -0,0 +1,32 @@
NameVirtualHost *:<%= @port %>
<VirtualHost *:<%= @port %>>
ServerName <%= @name %>
<%if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{@name}\n" %><% end
-%>
<% elsif @serveraliases != '' -%>
<%= " ServerAlias #{@serveraliases}" -%>
<% end -%>
DocumentRoot <%= @docroot %>
<Directory <%= @docroot %>>
Options Indexes FollowSymLinks MultiViews
AllowOverride None
Order allow,deny
allow from all
</Directory>
ErrorLog /var/log/apache2/<%= @name %>_error.log
LogLevel warn
CustomLog /var/log/apache2/<%= @name %>_access.log combined
ServerSignature On
</VirtualHost>
Each parameter specified in the definition is used, including the
$name
variable to name the virtual host
we’re creating.
You can also see some embedded Ruby in our ERB template :
<%if @serveraliases.is_a? Array -%>
<% @serveraliases.each do |name| -%><%= " ServerAlias #{@name}\n" %><% end
-%>
<% elsif @serveraliases != '' -%>
<%= " ServerAlias #{@serveraliases}" -%>
<% end -%>
30 changes: 30 additions & 0 deletions source-code-master/ch02/kickstart.ks
@@ -0,0 +1,30 @@
# Add Puppetlabs apt-repo gpg key
gpg --keyserver pgp.mit.edu --recv-keys 4BD6EC30 && gpg --export --armor 4BD6EC30 | apt-key add -
# Add Puppetlabs apt repo
cat > /etc/apt/sources.list.d/puppetlabs.list <<-EOF
CHAPTER 2 ■ BUILDING HOSTS WITH PUPPET
3
# puppetlabs
deb http://apt.puppetlabs.com precise main
deb-src http://apt.puppetlabs.com precise main
EOF
# Install puppet
/usr/bin/apt-get -y install puppet
# Make puppet startable
/bin/sed -i 's/START\=no/START\=yes/' '/etc/default/puppet'
# Create a puppet.conf file
cat > /etc/puppet/puppet.conf <<-EOF
[main]
logdir=/var/log/puppet
vardir=/var/lib/puppet
ssldir=/var/lib/puppet/ssl
rundir=/var/run/puppet
factpath=$vardir/lib/facter
pluginsync=true
runinterval=1380
configtimeout=600
splay=true
report=true
server = puppet.example.com
ca_server = puppetca.example.com
EOF
19 changes: 19 additions & 0 deletions source-code-master/ch02/mysql/manifests/config.pp
@@ -0,0 +1,19 @@
class mysql::config (
$user,
$group,
){
file { '/opt/csw/mysql5/my.cnf':
ensure => present,
source => 'puppet:///modules/mysql/my.cnf',
owner => $user,
group => $group,
require => Class['mysql::install'],
notify => Class['mysql::service'],
}
file { '/opt/csw/mysql5/var':
group => $user,
owner => $group,
recurse => true,
require => File['/opt/csw/mysql5/my.cnf'],
}
}
19 changes: 19 additions & 0 deletions source-code-master/ch02/mysql/manifests/init.pp
@@ -0,0 +1,19 @@
class mysql (
$group = 'mysql',
$service_enabled = true,
$service_running = true,
$user = 'mysql'
){
class { 'mysql::install':
user => $user,
group => $group,
}
class { 'mysql::config':
user => $user,
group => $group,
}
class { 'mysql::service':
ensure => $service_running,
enabled => $service_enabled,
}
}
26 changes: 26 additions & 0 deletions source-code-master/ch02/mysql/manifests/install.pp
@@ -0,0 +1,26 @@
class mysql::install (
$user,
$group
){

$mysql_pkgs = ['mysql5',
'mysql5client',
'mysql5rt',
'mysql5test',
'mysql5devel' ]

package { $mysql_pkgs:
ensure => present,
require => User[$user],
}
user { $user:
ensure => present,
comment => 'MySQL user',
gid => $group,
shell => '/bin/false',
require => Group[$group],
}
group { $group:
ensure => present,
}
}
12 changes: 12 additions & 0 deletions source-code-master/ch02/mysql/manifests/service.pp
@@ -0,0 +1,12 @@
class mysql::service (
enabled,
ensure,
){
service { 'cswmysql5':
ensure => $ensure,
hasstatus => true,
hasrestart => true,
enabled => $enabled,
require => Class['mysql::config'],
}
}
19 changes: 19 additions & 0 deletions source-code-master/ch02/postfix/manifests/config.pp
@@ -0,0 +1,19 @@
class postfix::config {
File {
owner => 'postfix',
group => 'postfix',
mode => 0644,
}
file { '/etc/postfix/master.cf':
ensure => present,
source => 'puppet:///modules/postfix/master.cf',
require => Class['postfix::install'],
notify => Class['postfix::service'],
}
file { '/etc/postfix/main.cf':
ensure => present,
content => template('postfix/main.cf.erb'),
require => Class['postfix::install'],
notify => Class['postfix::service'],
}
}
5 changes: 5 additions & 0 deletions source-code-master/ch02/postfix/manifests/init.pp
@@ -0,0 +1,5 @@
class postfix {
include postfix::install
include postfix::config
include postfix::service
}
5 changes: 5 additions & 0 deletions source-code-master/ch02/postfix/manifests/package.pp
@@ -0,0 +1,5 @@
class postfix::package {
package { [ "postfix", "mailx" ]:
ensure => present,
}
}
9 changes: 9 additions & 0 deletions source-code-master/ch02/postfix/manifests/service.pp
@@ -0,0 +1,9 @@
class postfix::service {
service { 'postfix':
ensure => running,
hasstatus => true,
hasrestart => true,
enable => true,
require => Class['postfix::config'],
}
}
14 changes: 14 additions & 0 deletions source-code-master/ch02/postfix/templates/postfix.cf.erb
@@ -0,0 +1,14 @@
soft_bounce = no
command_directory = /usr/sbin
daemon_directory = /usr/libexec/postfix
mail_owner = postfix
myhostname = <%= @hostname %>
mydomain = <%= @domain %>
myorigin = $mydomain
mydestination = $myhostname, localhost.$mydomain, localhost, $mydomain
unknown_local_recipient_reject_code = 550
relay_domains = $mydestination
smtpd_reject_unlisted_recipient = yes
unverified_recipient_reject_code = 550
smtpd_banner = $myhostname ESMTP
setgid_group = postdrop

0 comments on commit a416b7a

Please sign in to comment.