Read Pro Puppet Online

Authors: Jeffrey McCune James Turnbull

Pro Puppet (57 page)

BOOK: Pro Puppet
3.28Mb size Format: txt, pdf, ePub
ads

The RabbitMQ server software alone is not sufficient to provide messaging services for MCollective. Two additional plugins for RabbitMQ need to be installed to provide Stomp protocol support and AMQP protocol support. These plugins are specific to the version of RabbitMQ installed and are available online at:
http://www.rabbitmq.com/plugins.html
.
Listing 11-4
references RabbitMQ version 2.3.1. If there is a new version of RabbitMQ available at the time of writing, please update the environment variable to reflect your version.

Listing 11-4.
Installing the RabbitMQ AMQP and Stomp plugins on Debian

$ rabbitmq_version=2.3.1
$ cd /usr/lib/rabbitmq/lib/rabbitmq_server-${rabbitmq_version}/plugins/
$ sudo wget -q http://www.rabbitmq.com/releases/plugins/v${rabbitmq_version}
/amqp_client-${rabbitmq_version}.ez
$ sudo wget -q http://www.rabbitmq.com/releases/plugins/v${rabbitmq_version}
/rabbit_stomp-${rabbitmq_version}.ez
$ sudo /sbin/service rabbitmq-server restart
Restarting rabbitmq-server: SUCCESS
rabbitmq-server.

The operator changes directories to the plugin directory for RabbitMQ. This directory is specific to the version of RabbitMQ installed and may need to be adjusted slightly if you have not installed version 2.3.1 of RabbitMQ on your system. Once in the plugin directory, the operator downloads the
amqp_client
and
rabbit_stomp
Erlang modules. Finally, to activate the plugins, the operator restarts the
rabbitmq-server
service. Once the RabbitMQ software and plugins have been installed, please proceed to the RabbitMQ Configuration section.

Installing RabbitMQ on RHEL / CentOS

Similar to installation on Debian-based systems, RabbitMQ on Enterprise Linux systems requires the Erlang runtime to be installed first. RabbitMQ packages are also available for Enterprise Linux, and the operator uses these packages to install the RabbitMQ software. Finally, the plugins to enable Stomp in RabbitMQ need to be installed.
Listing 11-5
illustrates how the operator performs these tasks on an Enterprise Linux system. Please remember only one system needs to run the RabbitMQ service, and all MCollective clients and servers will connect to this system to exchange messages.

Listing 11-5.
Install RabbitMQ on Enterprise Linux

$ sudo yum -y install erlang

$ sudo rpm -Uvh http://www.rabbitmq.com/releases/rabbitmq-server/v2.3.1
/rabbitmq-server-2.3.1-1.noarch.rpm
Retrieving http://www.rabbitmq.com/releases/rabbitmq-server/v2.3.1
/rabbitmq-server-2.3.1-1.noarch.rpm
Preparing...               ########################################### [100%]
   1:rabbitmq-server        ########################################### [100%]

The operator first installs the Erlang runtime from the Enterprise Linux package repository. Erlang is included in the Enterprise Linux distribution, so no third party packages are required. Unfortunately,
RabbitMQ is not included in the distribution. The operator uses the
rpm
command to directly install the RabbitMQ server software from the upstream vendor. Please check
http://www.rabbitmq.com
to find out if more recent releases are available for Enterprise Linux systems.

Once the server software is installed, the Stomp connector plugins need to be installed. These plugins should be placed into
/usr/lib/rabbitmq/lib/rabbitmq_server-2.3.1/plugins
on Enterprise Linux systems. The installation of the plugins is shown in
Listing 11-6
.

Listing 11-6.
Installing RabbitMQ Stomp plugins

$ cd /usr/lib/rabbitmq/lib/rabbitmq_server-2.3.1/plugins
$ sudo wget -q http://www.rabbitmq.com/releases/plugins/v2.3.1/amqp_client-2.3.1.ez
$ sudo wget -q http://www.rabbitmq.com/releases/plugins/v2.3.1/rabbit_stomp-2.3.1.ez
$ sudo chmod 644 *.ez
$ sudo /sbin/rabbitmq-server restart
Restarting rabbitmq-server: No nodes running
SUCCESS
rabbitmq-server.

Similar to the Debian installation, the operator downloads the AMQP and Stomp connector libraries into the RabbitMQ plugins directory and then restarts the
rabbitmq-server
service. Once the service has been restarted, the operator proceeds to configure RabbitMQ to enable the Stomp protocol and listen on TCP port 6163.

RabbitMQ Configuration

Once the RabbitMQ packages and plugins have been installed, some configuration is required. The configuration of RabbitMQ for use with MCollective is identical for both Debian-based and Enterprise Linux-based systems. As mentioned in the installation sections, MCollective communicates using the Stomp protocol. The use of the Stop protocol required the installation of the AMQP and Stop plugins for RabbitMQ in the previous section.

The Example.com operator reconfigures RabbitMQ to enable the Stomp listener on TCP Port 6163. The configuration file for RabbitMQ is located at
/etc/rabbitmq/rabbitmq.config
and needs to contain only a single line to change the Stomp port. In
Listing 11-7
, see how the operator uses Puppet to make sure this line is present in the configuration file.

Listing 11-7.
Configuring the the RabbitMQ Stomp listener

$ sudo puppet resource file /etc/rabbitmq/rabbitmq.config \
 content='[ {rabbit_stomp, [{tcp_listeners, [6163]} ]} ].'
file { '/etc/rabbitmq/rabbitmq.config':
    ensure => 'file',    content => '{md5}8e195d71567368ea5446930bce473952
}

Using the
puppet resource
command, the operator manages the contents of the
rabbitmq.config
configuration file. Finally, the RabbitMQ server should be restarted to configure the Stomp listener (see
Listing 11-8
).

Listing 11-8.
Restarting RabbitMQ and verifying Stomp TCP port

$ sudo /sbin/service rabbitmq-server restart
Restarting rabbitmq-server: SUCCESS
rabbitmq-server.
$ sudo netstat -nlp | grep 6163
tcp6       0      0 :::6163                 :::*                    LISTEN      3424/beam

The operator first restarts the
rabbitmq-server
service, then uses the
netstat
command to verify that Port 6163 is bound and listening. The beam process is the main RabbitMQ process and is correctly bound to port 6163 in
Listing 11-8
. If you do not see the beam process bound to port 6163, please verify the
rabbimq.conf
configuration file syntax.

Listing 11-9
shows the last step of configuring RabbitMQ for use with MCollective. This step creates a user account in RabbitMQ for MCollective to use. The MCollective client and server processes will use this information to make Stomp connections to RabbitMQ.

Listing 11-9.
Configuring the RabbitMQ MCollective account

$ sudo rabbitmqctl add_user mcollective iwillchangethispassword
Creating user "mcollective" ...
...done.
$ sudo rabbitmqctl set_permissions -p / mcollective "^amq.gen-.*" ".*" ".*"
Setting permissions for user "mcollective" in vhost "/" ...
...done.

The operator uses the
rabbitmqctl
command to add the
mcollective
account with a password. Once added, permissions are granted to allow MCollective client and server processes to exchange messages. More information about RabbitMQ accounts and permissions is available online at
http://www.rabbitmq.com/admin-guide.html
.

Finally, RabbitMQ configures a default guest account with full access to the message queues. For security purposes the guest account should be deleted using the
delete_user
action shown in
Listing 11-10
.

Listing 11-10.
Removing the RabbitMQ guest account

$ sudo rabbitmqctl delete_user guest
Deleting user "guest" ...
...done.

Once the guest account has been deleted, RabbitMQ is ready for use with MCollective. Let's move on to installing the MCollective software and configuring the client and server to communicate through the new RabbitMQ message service.

Installing MCollective on Debian and Ubuntu

In the previous sections, the RabbitMQ middleware service had been installed and configured on a central server system. The operator will now install and configure the MCollective software to connect with the messaging middleware. Each managed node will run the MCollective server process to receive
messages and act upon them. The MCollective client program provides the command line interface to communicate with the MCollective servers.

On Debian-based systems, installation of MCollective is straight–forward, using the packages provided at
http://puppetlabs.com/downloads/
. On a node being managed, the operator downloads two packages: the common package and the server package. See how he does this in
Listing 11-11
.

Listing 11-11.
Installing MCollective packages on Debian-based systems

$ mkdir /var/tmp/mcollective
$ cd /var/tmp/mcollective
$ wget http://www.puppetlabs.com/downloads/mcollective/mcollective-common_1.0.1-1_all.deb
$ wget http://www.puppetlabs.com/downloads/mcollective/mcollective_1.0.1-1_all.deb
$ sudo dpkg -i mcollective*.deb
Selecting previously deselected package mcollective.
(Reading database ... 40800 files and directories currently installed.)
Unpacking mcollective (from mcollective_1.0.1-1_all.deb) ...
Selecting previously deselected package mcollective-common.
Unpacking mcollective-common (from mcollective-common_1.0.1-1_all.deb) ...
Setting up mcollective-common (1.0.1-1) ...
Setting up mcollective (1.0.1-1) ...

Only these two packages need to be installed on nodes MCollective is going to be managing. On nodes where MCollective commands will be executed, the MCollective client package also needs to be installed, as shown in
Listing 11-12
. The MCollective servers will execute actions through the use of agent plugins. These agents will be invoked using a remote procedure call command,
mc-rpc
, contained in the
mcollective-client
package.

BOOK: Pro Puppet
3.28Mb size Format: txt, pdf, ePub
ads

Other books

InTooDeep by Rachel Carrington
The Collective by Stephen King
Fragmentos de honor by Lois McMaster Bujold
B005N8ZFUO EBOK by Lubar, David
The Fallen (Book 1) by Dan O'Sullivan
Elei's Chronicles (Books 1-3) by Thoma, Chrystalla
Nightmare City by Nick Oldham
Sympathy between humans by Jodi Compton