Using Passenger
Version 9 (Al Tobey, 07/09/2010 06:19 pm)
| 1 | 1 | # Using Passenger |
|
|---|---|---|---|
| 2 | 1 | ||
| 3 | 1 | **This support is present in release 0.24.6 and later versions only - it is not supported in earlier releases** |
|
| 4 | 1 | ||
| 5 | 1 | Alternatively see: [[Using Mongrel]] |
|
| 6 | 1 | ||
| 7 | 1 | ## Why You'd Do This |
|
| 8 | 1 | ||
| 9 | 6 | micah - | Traditionally, the puppetmaster would embed a WEBrick or Mongrel Web Server to serve the puppet clients. This may work well for you, but a few people feel like using a proven web server like Apache would be superior for this purpose. |
| 10 | 1 | ||
| 11 | 1 | ## What is Passenger ? |
|
| 12 | 1 | ||
| 13 | 6 | micah - | [Passenger](http://www.modrails.com/) (AKA mod\_rails or mod\_rack) is the Apache 2.x Extension which lets you run Rails or Rack applications inside Apache. |
| 14 | 1 | ||
| 15 | 6 | micah - | Puppet (>0.24.6) now ships with a Rack application which can embed a puppetmaster. While it should be compatible with every Rack application server, it has only been tested with Passenger. |
| 16 | 1 | ||
| 17 | 6 | micah - | Depending on your operating system, the versions of Puppet, Apache and Passenger may not support this implementation. Specifically, Ubuntu Hardy ships with an older version of puppet (0.24.4) and doesn't include passenger at all, however updated packages for puppet can be found [here](https://launchpad.net/~bitpusher/+archive/ppa). There are also some passenger packages there, but as of 2009-09-28 they do not seem to have the latest passenger (2.2.5), so better install passenger from a gem as per the instructions at [modrails.com]. |
| 18 | 1 | ||
| 19 | 1 | ## Dependency versions |
|
| 20 | 1 | ||
| 21 | 1 | **Puppet: (>0.24.6)** |
|
| 22 | 1 | ||
| 23 | 3 | Patrick Mohr | **Passenger: See below** |
| 24 | 1 | ||
| 25 | 1 | **Rack: version 1.0.0 is known to work. 0.3.0 is known to NOT work** |
|
| 26 | 1 | ||
| 27 | 7 | Jeff McCune | **JJM Recommended Versions: As of July 2010, Passenger 2.2.11 and Rack 1.0.1 are confirmed to be working. To install, gem install -v=1.0.1 rack, gem install -v=2.2.11 passenger** |
| 28 | 7 | Jeff McCune | |
| 29 | 6 | micah - | Note: Passenger versions 2.2.3 and 2.2.4 have known bugs regarding to the SSL environment variables, which make them unsuitable for hosting a puppetmaster. So use either 2.2.2, or 2.2.5. Note that while it was expected that Passenger 2.2.2 would be the last version which can host a 0.24.x puppetmaster, that turns out to be |
| 30 | 6 | micah - | not true, cf. [this bug report](http://projects.reductivelabs.com/issues/2386#change-9238). So, passenger 2.2.5 works fine. |
| 31 | 1 | ||
| 32 | 9 | Al Tobey | Another Note: It appears that the Rack 0.4.0 distributed in EPEL does not work with Puppet 0.25.5 or 0.26 (git as of 2010-07-09). Updating Rack to 1.0.1 as recommended above makes things start working. |
| 33 | 9 | Al Tobey | |
| 34 | 6 | micah - | ## Installation Summary for Debian/Ubuntu and RHEL5 |
| 35 | 1 | ||
| 36 | 6 | micah - | Please see [ext/rack/README in the puppet source](http://github.com/reductivelabs/puppet/tree/master/ext/rack) tree for instructions. |
| 37 | 1 | ||
| 38 | 1 | Whatever you do, make sure your config.ru file is owned by the puppet user! Passenger will setuid to that user. |
|
| 39 | 1 | ||
| 40 | 1 | Make sure puppetmasterd ran at least once, so puppetmasterd SSL certificates are setup initially. |
|
| 41 | 1 | ||
| 42 | 5 | micah - | ### Setup your puppet.conf |
| 43 | 1 | ||
| 44 | 1 | Make sure you have the following set in your puppetmaster's puppet.conf: |
|
| 45 | 5 | micah - | |
| 46 | 1 | [puppetmasterd]] |
|
| 47 | 5 | micah - | ssl_client_header = SSL_CLIENT_S_DN |
| 48 | 1 | ssl_client_verify_header = SSL_CLIENT_VERIFY |
|
| 49 | 5 | micah - | |
| 50 | 5 | micah - | ### Install Apache2, Rack and Passenger |
| 51 | 5 | micah - | |
| 52 | 6 | micah - | For Debian/Ubuntu you just need to do the following (no gems needed): |
| 53 | 5 | micah - | |
| 54 | 1 | apt-get install apache2 libapache2-mod-passenger librack-ruby |
|
| 55 | 5 | micah - | |
| 56 | 1 | NOTE: you should have 0.25.4-6 or later of the puppetmaster package installed |
|
| 57 | 5 | micah - | NOTE2: if you are running Debian Stable (ie. Lenny), you will need to use the [backports.org packages](http://backports.org), specifically make sure you install at least version 2.2.11debian-1~bpo50+1 of libapache2-mod-passenger, and 1.0.0-2~bpo50+1 of librack-ruby. The rack library in Lenny is too old, and passenger does not exist in Lenny. |
| 58 | 5 | micah - | |
| 59 | 6 | micah - | For RHEL5 (needs the [EPEL](https://fedoraproject.org/wiki/EPEL) repository enabled) do the following: |
| 60 | 1 | ||
| 61 | 1 | yum install httpd httpd-devel ruby-devel rubygems |
|
| 62 | 6 | micah - | The latest version of Passenger (2.2.5) appears to work fine on RHEL5: |
| 63 | 1 | gem install rack |
|
| 64 | 1 | gem install passenger |
|
| 65 | 1 | passenger-install-apache2-module |
|
| 66 | 1 | ||
| 67 | 6 | micah - | If you want the older 2.2.2 gem, you could manually download the .gem file from [RubyForge](http://rubyforge.org/frs/?group_id=5873). Or, you could just add the |
| 68 | 6 | micah - | correct versions to your gem command: |
| 69 | 1 | ||
| 70 | 1 | gem install -v 0.4.0 rack |
|
| 71 | 1 | gem install -v 2.2.2 passenger |
|
| 72 | 1 | ||
| 73 | 6 | micah - | Enable Apache modules "ssl" and "headers": |
| 74 | 1 | ||
| 75 | 5 | micah - | # for RHEL5 |
| 76 | 5 | micah - | yum install mod_ssl |
| 77 | 5 | micah - | |
| 78 | 5 | micah - | # Debian and Ubuntu have these enabled by default, but if you need to, this is how you enable them: |
| 79 | 1 | a2enmod ssl |
|
| 80 | 1 | a2enmod headers |
|
| 81 | 1 | ||
| 82 | 1 | ||
| 83 | 1 | ### Configure Apache |
|
| 84 | 1 | ||
| 85 | 1 | For Debian/Ubuntu: |
|
| 86 | 1 | ||
| 87 | 5 | micah - | cp /usr/share/doc/puppetmaster/examples/apache2.conf /etc/apache2/sites-available/puppetmasterd (see below for the file contents) |
| 88 | 5 | micah - | $EDITOR /etc/apache2/conf.d/puppetmasterd (replace the hostnames) |
| 89 | 5 | micah - | a2ensite puppetmasterd |
| 90 | 1 | ||
| 91 | 1 | For RHEL5: |
|
| 92 | 1 | ||
| 93 | 1 | cp puppetmaster.conf /etc/httpd/conf.d/ (see below for file contents) |
|
| 94 | 1 | vim /etc/httpd/conf.d/puppetmaster.conf (replace hostnames with corrent values) |
|
| 95 | 1 | ||
| 96 | 5 | micah - | Install the rack application [1] (Debian users do not need to do this) |
| 97 | 1 | ||
| 98 | 1 | mkdir -p /usr/share/puppet/rack/puppetmasterd |
|
| 99 | 1 | mkdir /usr/share/puppet/rack/puppetmasterd/public /usr/share/puppet/rack/puppetmasterd/tmp |
|
| 100 | 1 | cp config.ru /usr/share/puppet/rack/puppetmasterd |
|
| 101 | 1 | chown puppet /usr/share/puppet/rack/puppetmasterd/config.ru |
|
| 102 | 1 | ||
| 103 | 5 | micah - | Restart apache: |
| 104 | 1 | ||
| 105 | 1 | # For Debian/Ubuntu |
|
| 106 | 5 | micah - | /etc/init.d/puppetmaster stop - make sure puppetmaster is stopped before you continue |
| 107 | 1 | /etc/init.d/apache2 restart |
|
| 108 | 1 | ||
| 109 | 1 | # For RHEL5 |
|
| 110 | 1 | /etc/init.d/httpd restart |
|
| 111 | 1 | ||
| 112 | 5 | micah - | If all works well, you'll want to make sure your puppmetmasterd init script does not get called anymore: |
| 113 | 1 | ||
| 114 | 1 | # For Debian/Ubuntu |
|
| 115 | 5 | micah - | $EDITOR /etc/default/puppetmaster - change START=yes to START=no |
| 116 | 5 | micah - | |
| 117 | 1 | # For RHEL5 |
|
| 118 | 1 | chkconfig puppetmaster off |
|
| 119 | 1 | chkconfig httpd on |
|
| 120 | 1 | ||
| 121 | 1 | [1] Passenger will not let applications run as root or the Apache user, instead an implicit setuid will be done, to the user whom owns config.ru. Therefore, config.ru shall be owned by the puppet user. |
|
| 122 | 5 | micah - | |
| 123 | 1 | ## Apache Configuration for Puppet 0.24.x |
|
| 124 | 1 | ||
| 125 | 1 | This Apache Virtual Host configures the puppetmaster on the default |
|
| 126 | 1 | puppetmaster port (8140). |
|
| 127 | 1 | ||
| 128 | 1 | Listen 8140 |
|
| 129 | 1 | <VirtualHost *:8140> |
|
| 130 | 1 | ||
| 131 | 1 | SSLEngine on |
|
| 132 | 1 | SSLCipherSuite SSLv2:-LOW:-EXPORT:RC4+RSA |
|
| 133 | 1 | SSLCertificateFile /var/lib/puppet/ssl/certs/puppet-server.inqnet.at.pem |
|
| 134 | 1 | SSLCertificateKeyFile /var/lib/puppet/ssl/private_keys/puppet-server.inqnet.at.pem |
|
| 135 | 1 | SSLCertificateChainFile /var/lib/puppet/ssl/ca/ca_crt.pem |
|
| 136 | 1 | SSLCACertificateFile /var/lib/puppet/ssl/ca/ca_crt.pem |
|
| 137 | 1 | # CRL checking should be enabled; if you have problems with Apache complaining about the CRL, disable the next line |
|
| 138 | 1 | SSLCARevocationFile /var/lib/puppet/ssl/ca/ca_crl.pem |
|
| 139 | 1 | SSLVerifyClient optional |
|
| 140 | 1 | SSLVerifyDepth 1 |
|
| 141 | 1 | SSLOptions +StdEnvVars |
|
| 142 | 1 | ||
| 143 | 1 | # The following client headers allow the same configuration to work with Pound. |
|
| 144 | 1 | RequestHeader set X-SSL-Subject %{SSL_CLIENT_S_DN}e |
|
| 145 | 1 | RequestHeader set X-Client-DN %{SSL_CLIENT_S_DN}e |
|
| 146 | 1 | RequestHeader set X-Client-Verify %{SSL_CLIENT_VERIFY}e |
|
| 147 | 1 | ||
| 148 | 1 | RackAutoDetect On |
|
| 149 | 1 | DocumentRoot /usr/share/puppet/rack/puppetmasterd/public/ |
|
| 150 | 1 | <Directory /usr/share/puppet/rack/puppetmasterd/> |
|
| 151 | 1 | Options None |
|
| 152 | 1 | AllowOverride None |
|
| 153 | 1 | Order allow,deny |
|
| 154 | 1 | allow from all |
|
| 155 | 1 | </Directory> |
|
| 156 | 1 | </VirtualHost> |
|
| 157 | 1 | ||
| 158 | 1 | If the current puppetmaster is not a certificate authority, you may |
|
| 159 | 1 | need to change the following lines. The certs/ca.pem file should |
|
| 160 | 1 | exist as long as the puppetmaster has been signed by the CA. |
|
| 161 | 1 | ||
| 162 | 1 | SSLCertificateChainFile /var/lib/puppet/ssl/certs/ca.pem |
|
| 163 | 6 | micah - | SSLCACertificateFile /var/lib/puppet/ssl/certs/ca.pem |
| 164 | 1 | ||
| 165 | 1 | For RHEL hosts you may need to add: |
|
| 166 | 1 | ||
| 167 | 1 | LoadModule passenger_module /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5/ext/apache2/mod_passenger.so |
|
| 168 | 1 | PassengerRoot /usr/lib/ruby/gems/1.8/gems/passenger-2.2.5 |
|
| 169 | 1 | PassengerRuby /usr/bin/ruby |
|
| 170 | 1 | ||
| 171 | 5 | micah - | For details about enabling and configuring Passenger, see the [Passenger install guide](http://www.modrails.com/install.html). |
| 172 | 1 | ||
| 173 | 1 | ## The config.ru file for Puppet 0.24.x |
|
| 174 | 1 | ||
| 175 | 1 | # This file is mostly based on puppetmasterd, which is part of |
|
| 176 | 1 | # the standard puppet distribution. |
|
| 177 | 1 | ||
| 178 | 1 | require 'rack' |
|
| 179 | 1 | require 'puppet' |
|
| 180 | 1 | require 'puppet/network/http_server/rack' |
|
| 181 | 1 | ||
| 182 | 1 | # startup code stolen from bin/puppetmasterd |
|
| 183 | 1 | Puppet.parse_config |
|
| 184 | 1 | Puppet::Util::Log.level = :info |
|
| 185 | 1 | Puppet::Util::Log.newdestination(:syslog) |
|
| 186 | 1 | # A temporary solution, to at least make the master work for now. |
|
| 187 | 1 | Puppet::Node::Facts.terminus_class = :yaml |
|
| 188 | 1 | # Cache our nodes in yaml. Currently not configurable. |
|
| 189 | 1 | Puppet::Node.cache_class = :yaml |
|
| 190 | 1 | ||
| 191 | 1 | ||
| 192 | 1 | # The list of handlers running inside this puppetmaster |
|
| 193 | 1 | handlers = { |
|
| 194 | 1 | :Status => {}, |
|
| 195 | 1 | :FileServer => {}, |
|
| 196 | 1 | :Master => {}, |
|
| 197 | 1 | :CA => {}, |
|
| 198 | 1 | :FileBucket => {}, |
|
| 199 | 1 | :Report => {} |
|
| 200 | 1 | } |
|
| 201 | 1 | ||
| 202 | 1 | # Fire up the Rack-Server instance |
|
| 203 | 1 | server = Puppet::Network::HTTPServer::Rack.new(handlers) |
|
| 204 | 1 | ||
| 205 | 1 | # prepare the rack app |
|
| 206 | 1 | app = proc do |env| |
|
| 207 | 1 | server.process(env) |
|
| 208 | 1 | end |
|
| 209 | 1 | ||
| 210 | 1 | # Go. |
|
| 211 | 1 | run app |
|
| 212 | 1 | ||
| 213 | 5 | micah - | If you don't want to run with the CA enabled, you could drop the :CA => {} line from the config.ru above. |
| 214 | 1 | ||
| 215 | 1 | ## The config.ru file for 0.25.x |
|
| 216 | 1 | ||
| 217 | 5 | micah - | Please see ext/rack in the 0.25 source tree for the proper config.ru file. |
| 218 | 1 | ||
| 219 | 1 | ## Suggested Tweaks |
|
| 220 | 1 | ||
| 221 | 5 | micah - | Based upon my (Larry Ludwig) testing of passenger/puppetmasterd I recommend adjusting these options in your apache configuration. |
| 222 | 1 | ||
| 223 | 1 | - PassengerPoolIdleTime 300 - Set to 5 min (300 seconds) or less. |
|
| 224 | 1 | The shorting this option allows for puppetmasterd to get refreshed |
|
| 225 | 1 | at some interval. This option is also somewhat dependent upon the |
|
| 226 | 1 | amount of puppetd nodes connecting and at what interval. |
|
| 227 | 1 | - PassengerMaxPoolSize 15 - to 15% more instances than what's |
|
| 228 | 1 | needed. This will allow idle puppetmasterd to get recycled. The net |
|
| 229 | 1 | effect is less memory will be used, not more. |
|
| 230 | 1 | - PassengerUseGlobalQueue on - Since communication with the |
|
| 231 | 1 | puppetmaster from puppetd is a long process (more than 20 seconds |
|
| 232 | 1 | in most cases) and will allow for processes to get recycled better |
|
| 233 | 1 | - PassengerHighPerformance on - The additional Passenger features |
|
| 234 | 1 | for apache compatibility are not needed with Puppet. |
|
| 235 | 1 | ||
| 236 | 5 | micah - | No different than with traditional web servers, once your service starts using swap performance degradation will occur. So be mindful of your memory/swap usage on your Puppetmaster. |
| 237 | 1 | ||
| 238 | 5 | micah - | To monitor the age of your puppetmasterd processes within Passenger, run |
| 239 | 1 | ||
| 240 | 1 | passenger-status | grep PID | sort |
|
| 241 | 1 | ||
| 242 | 1 | PID: 14590 Sessions: 1 Processed: 458 Uptime: 3m 40s |
|
| 243 | 1 | PID: 7117 Sessions: 0 Processed: 10980 Uptime: 1h 43m 41s |
|
| 244 | 1 | PID: 7355 Sessions: 0 Processed: 9736 Uptime: 1h 38m 38s |
|
| 245 | 1 | PID: 7575 Sessions: 0 Processed: 9395 Uptime: 1h 32m 27s |
|
| 246 | 1 | PID: 9950 Sessions: 0 Processed: 6581 Uptime: 1h 2m 35s |
|
| 247 | 1 | ||
| 248 | 1 | My personal preference is having Passenger recycling puppetmasterd every few hours to ensure memory/garbage collection from Ruby is not a factor. |
|
| 249 | 8 | Jeff McCune | |
| 250 | 8 | Jeff McCune | |
| 251 | 8 | Jeff McCune | ## Troubleshooting |
| 252 | 8 | Jeff McCune | |
| 253 | 8 | Jeff McCune | JJM GOTCHA: When working with Apache, make sure the CA certificate and the SSL certificate configured contain a different CN field. For example, if `/etc/puppet/ssl/certs/hyel.puppetlabs.lan.pem` and `/etc/puppet/ssl/ca/ca_crt.pem` have the same CN field, Apache will have an issue verifying certificate revocation lists. The error received looks like: `err: Could not retrieve catalog from remote server: tlsv1 alert decrypt error`. To fix, use the --ca_name configuration setting/option, e.g. ca_name = "Puppet CA" |