Report abuse

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
debug: //bootstrap::install_passenger_apache_module/Exec[install-passenger-apache-module]: Changing returns
debug: //bootstrap::install_passenger_apache_module/Exec[install-passenger-apache-module]: 1 change(s)
debug: //bootstrap::install_passenger_apache_module/Exec[install-passenger-apache-module]: Executing '/usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-install-apache2-module --auto'
debug: Executing '/usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-install-apache2-module --auto'
err: //bootstrap::install_passenger_apache_module/Exec[install-passenger-apache-module]/returns: change from notrun to 0 failed: /usr/lib/ruby/gems/1.8/gems/passenger-2.2.11/bin/passenger-install-apache2-module --auto returned 1 instead of one of [0] at /tmp/setup_puppetmaster.pp:67


# This script will setup a new box as a puppet master,
# running under apache and passenger.  This lets us
# scale quite well.
#
# You need to have a few things to make this work:
#
# 1. The EPEL repository (or alternatively the EPEL-testing
# repository if there are later versions of puppet installed)
#
# 2. The 'puppet' and 'puppet-server' packages installed
#
# Hopefully these things are already setup for you by cobbler.
#
# To get everything to work simply run:
#
# puppet --verbose setup_puppetmaster.pp

# liftoff
include bootstrap


# metaclass that just includes our sub-classes for clarity
class bootstrap {
  # Change this if you want a different version installed
  # The following are known working versions: 2.2.2, 2.2.11
  $passenger_version = "2.2.11"

  include bootstrap::packages
  include bootstrap::install_passenger_apache_module
  include bootstrap::modify_httpd_conf
  include bootstrap::fix_up_rack_files
  include bootstrap::install
}

# make sure we have all our necessary packages installed
class bootstrap::packages {

  package {
    [ "augeas", "apr-devel", "apr-util", "gcc", "gcc-c++", "httpd-devel", "ruby-devel", "rubygems", "make", "httpd" ]:
      ensure     => installed,
      before    => [ Package["rack"], Package["passenger"] ];

    [ "puppet-server" , "puppet" ]:
      ensure     => "0.25.4-1.el5";

     "rack":
      ensure     => installed,
      provider   => "gem",
      require   =>  Package["rubygems"];

     "passenger":
      ensure     => $passenger_version,
      provider   => "gem",
      require   =>  Package["rubygems"];
  }
}

# install 
class bootstrap::install_passenger_apache_module {

  exec { "install-passenger-apache-module":
    command => "/usr/lib/ruby/gems/1.8/gems/passenger-$passenger_version/bin/passenger-install-apache2-module --auto",
    creates => "/usr/lib/ruby/gems/1.8/gems/passenger-$passenger_version/ext/apache2/mod_passenger.so",
    before => Service["httpd"],
                path   => "/usr/bin",
    require => Package["passenger"];
  }
}

class bootstrap::modify_httpd_conf {

  Exec { path => "/bin:/usr/bin:/usr/sbin" }

  exec { "load-apache-module-httpd-conf":
    command => "sed -e '/mod_version.so/a\\LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-$passenger_version/ext/apache2/mod_passenger.so' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.new ; mv /etc/httpd/conf/httpd.conf.new /etc/httpd/conf/httpd.conf",
    unless  => "grep mod_passenger.so /etc/httpd/conf/httpd.conf",
    before   => Exec["specify-passenger-root-httpd-conf"],
    require => Package["httpd"];
  }

  exec { "specify-passenger-root-httpd-conf":
    command => "sed -e '/mod_passenger.so/a\\PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-$passenger_version' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.new ; mv /etc/httpd/conf/httpd.conf.new /etc/httpd/conf/httpd.conf",
    unless  => "grep PassengerRoot /etc/httpd/conf/httpd.conf",
    before   => Exec["specify-passenger-ruby-httpd-conf"],
    require => [ Package["httpd"], Exec["load-apache-module-httpd-conf"] ];
  }

  exec { "specify-passenger-ruby-httpd-conf":
    command => "sed -e '/mod_passenger.so/a\\PassengerRuby /usr/bin/ruby' /etc/httpd/conf/httpd.conf > /etc/httpd/conf/httpd.conf.new ; mv /etc/httpd/conf/httpd.conf.new /etc/httpd/conf/httpd.conf",
    unless  => "grep PassengerRuby /etc/httpd/conf/httpd.conf",
    require => [ Package["httpd"], Exec["specify-passenger-root-httpd-conf"] ];
  }
}

class bootstrap::fix_up_rack_files {

  #template for our apache configuration
  $content = "# you probably want to tune these settings
PassengerHighPerformance on
PassengerMaxPoolSize 12
PassengerPoolIdleTime 1500
# PassengerMaxRequests 1000
PassengerStatThrottleRate 120
RackAutoDetect Off
RailsAutoDetect Off

Listen 8140

<VirtualHost *:8140>
        SSLEngine on
        SSLProtocol -ALL +SSLv3 +TLSv1
        SSLCipherSuite ALL:!ADH:RC4+RSA:+HIGH:+MEDIUM:-LOW:-SSLv2:-EXP

        SSLCertificateFile      /var/lib/puppet/ssl/certs/squigley.namespace.at.pem
        SSLCertificateKeyFile   /var/lib/puppet/ssl/private_keys/squigley.namespace.at.pem
        SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem
        SSLCACertificateFile    /var/lib/puppet/ssl/ca/ca_crt.pem
        # If Apache complains about invalid signatures on the CRL, you can try disabling
        # CRL checking by commenting the next line, but this is not recommended.
        SSLCARevocationFile     /var/lib/puppet/ssl/ca/ca_crl.pem
        SSLVerifyClient optional
        SSLVerifyDepth  1
        SSLOptions +StdEnvVars

        DocumentRoot /etc/puppet/rack/public/
        RackBaseURI /
        <Directory /etc/puppet/rack/>
                Options None
                AllowOverride None
                Order allow,deny
                allow from all
        </Directory>
</VirtualHost>
"

  file { "/usr/share/puppet/ext/rack/files/apache2.conf":
    content => $content,
  }

  file { "/usr/share/puppet/ext/rack/files/config.ru":
    ensure   => present,
    owner   => "puppet",
    group   => "puppet",
    require => Package["puppet"],
  }
}

class bootstrap::install {

  file { ["/etc/puppet/rack", "/etc/puppet/rack/public"]:
      ensure => directory,
      mode   => 0755,
      owner  => root,
      group  => root,
  }

  file { "/etc/puppet/rack/config.ru":
     ensure  => present,
    source  => [ "puppet:///modules/rack/config.ru", "/usr/share/puppet/ext/rack/files/config.ru" ],
    mode  => 0644,
    owner  => puppet,
    group    => root,
    require => File[ "/usr/share/puppet/ext/rack/files/config.ru" ],
  }

  file { "/etc/httpd/conf.d/puppetmasterd":
    ensure   => present,
    source   => [ "puppet:///modules/rack/apache2.conf", "/usr/share/puppet/ext/rack/files/config.ru" ],
    mode   => 0644,
    owner   => root,
    group   => root,
    require => [File["/etc/puppet/rack/config.ru"], File["/etc/puppet/rack/public"], Package["httpd"], Package["passenger"]],
    notify   => Service["httpd"],
  }

  service { "httpd":
    ensure => running,
    require => Package["httpd"],
  }
}