Online Book Reader

Home Category

Pulling Strings With Puppet - James Turnbull [48]

By Root 371 0
used as a web server by Ruby on Rails applications, and you can learn more about it at http: //mongrel.rubyforge.org/.

With Mongrel integrated with Puppet, multiple puppetmasterd daemons can be run, each on a different port. A web server, in our case Apache, is placed in front of these instances, and the mod_proxy and mod_proxy_balancer modules are used to load balance connections to these instances.

Tip - Rather than Apache, you could also use other web servers. Other good choices include servers like lighthttd or nginx or a load balancer such as Pound. You can find instructions for running Mongrel with Pound at http: //reductivelabs.com/trac/puppet/wiki/UsingMongrelPound and with nginx at http://reductivelabs.com/trac/puppet/wiki/UsingMongrelNginx.

You can see a diagram that shows this architecture in Figure 6-1.

Figure 6-1. Puppet with Mongrel architecture

Installing Mongrel

The first step is to install Mongrel. There are three ways to install Mongrel-via package, via a Ruby Gem, or via source. In Table 6-2, I've listed the operating systems that currently have a package available for Mongrel. Also listed in Table 6-2 is the name of the relevant package. Your package management system may also prompt you to install additional packages.

You can also install Mongrel via a Ruby Gem if you have Ruby Gems installed.

Like packages, gem may prompt you to install additional packages.

Lastly, you can download and install Mongrel from source like so:

We don't have to do anything to configure Mongrel. Puppet will do this for us when we start the Puppet daemon.

Installing Apache

Next we need to install Apache. Many hosts already have Apache installed, and the mod_proxy and mod_proxy_balancer modules we need are installed with it. But if you need to install Apache, you can do it via package or source. These packages generally also include all of the required modules we need to integrate Apache with Mongrel and Puppet, and you can see the list in Table 6-3.

Your package management system may also prompt you to install additional packages as dependencies to Apache.

If you haven't got a suitable package, you can also download and install the latest version of Apache via source. I have chosen to download from a mirror in Australia, but you can check the Apache download page at http://httpd.apache.org/download.cgi to find an appropriate mirror. In Listing 6-9, we've downloaded, unpacked, and configured Apache.

In Listing 6-9, we've configured (including enabled Apache modules), compiled, and installed Apache into the directory /usr/local/apache2.

Configuring Apache As a Proxy

After you've installed Apache, you need to configure it. To do this we need to configure a virtual host, proxy balancing, and SSL, which entails creating an SSL-enabled virtual host that will be proxy balanced back to our puppetmasterd daemons running Mongrel. You can see an example of a simple Apache configuration to do this in Listing 6-10.

Let's examine the configuration we've specified in Listing 6-10. We start by running Apache on port 8140 so that our clients don't require any reconfiguration to connect to our new proxy. Next, we specify a process ID file in a directory we're going to create for our server.

We then specify the user and group name that we want Apache to run as. This should be the same as the user and group that the puppetmasterd daemon runs as. In our case, this is the user and group puppet.

Then in Listing 6-10, we've specified a number of LoadModule statements. These load the required modules, such as the mod_proxy_balancer module, needed to run our Apache proxy. The required modules are as follows:

• mod_proxy

• mod_proxy_http

• mod_proxy_balancer

• mod headers

• mod ssl

• mod authz host

• mod_log_config

For Red Hat-style distributions, the Apache daemon tries to load all available modules, and you can see the LoadModule statements in your Apache configuration file, for example, /etc/httpd/conf/httpd.conf on a Red Hat platform, for the required modules. The LoadModule statements in Listing

Return Main Page Previous Page Next Page

®Online Book Reader