MCollective with rabbitMQ

Requirements

This howto is about installing MCollective and RabbitMQ on debian7 based servers. In order to achieve the installation process you will need to install on the MCollective Master :

apt-get install git libstomp-ruby1.9.1 -y #on mcollective master
apt-get install ntp # on all nodes !

RabbitMQ

First add rabbitmq testing repo for debian based system :

# /etc/apt/sources.list.d/rabbitmq.list
deb http://www.rabbitmq.com/debian/ testing main

Don't forget to add rabbitmq pgp key for this new repo :

wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
apt-key add rabbitmq-signing-key-public.asc

# now update
apt-get update

install the package rabbitmq-server :

apt-get install rabbitmq-server -y

Another tool is missing on the system : rabbitmqadmin. So add it manually, or dl it from :

http://hg.rabbitmq.com/rabbitmq-management/raw-file/rabbitmq_v3_2_1/bin/rabbitmqadmin

Install rabbitmq_management plugin and rabbitmq_stomp, in order to have rabbitmqadmin to works without errors and mcollective adaptor ok :

rabbitmq-plugins enable rabbitmq_management
rabbitmq-plugins enable rabbitmq_stomp

Configure out rabbitmq in /etc/rabbitmq/rabbitmq.config file :

[
 {rabbit,
 [
   {tcp_listeners, [{"127.0.0.1", 5672},
                    {"::1",       5672}]}
 ]
  },
 {kernel,
 []
  },
 {rabbitmq_management,
 []
  },
 {rabbitmq_management_agent,
 []
  },
 {rabbitmq_shovel,
  []
  },
 {rabbitmq_stomp,
 []
  },
 {rabbitmq_mqtt,
 []
  },
 {rabbitmq_amqp1_0,
 []
  },
 {rabbitmq_auth_backend_ldap,
 []
  }
].

Now restart rabbitmq service :

/etc/init.d/rabbitmq-server restart

No errors should be found in order rabbitmq to work.

Now configure the rabbitmq server in order to work with MCollective. Create a first vhost and two users, one to act as an admin and the other for mcollective :

rabbitmqctl add_vhost /mcollective
rabbitmqctl add_user mcollective changeme
rabbitmqctl add_user adminUser adminPass
rabbitmqctl set_user_tags adminUser administrator
rabbitmqctl set_permissions -p /mcollective mcollective "^mcollective-.*" ".*" ".*"
rabbitmqctl set_permissions -p /mcollective adminUser ".*" ".*" ".*"

Now create the exchanges neededfor each mcollective :

for collective in mcollective ; do
        rabbitmqadmin declare exchange --user=adminUser --password=adminPass --vhost=/mcollective name=${collective}_broadcast type=topic
        rabbitmqadmin declare exchange --user=adminUer --password=adminPass --vhost=/mcollective name=${collective}_directed type=direct
done

Verifying everything is ok and service will be working fine :

rabbitmqadmin -u adminUser -p adminPass -V /mcollective list exchanges
+--------------+-----------------------+---------+-------------+---------+----------+
|    vhost     |         name          |  type   | auto_delete | durable | internal |
+--------------+-----------------------+---------+-------------+---------+----------+
| /mcollective |                       | direct  | False       | True    | False    |
| /mcollective | amq.direct            | direct  | False       | True    | False    |
| /mcollective | amq.fanout            | fanout  | False       | True    | False    |
| /mcollective | amq.headers           | headers | False       | True    | False    |
| /mcollective | amq.match             | headers | False       | True    | False    |
| /mcollective | amq.rabbitmq.trace    | topic   | False       | True    | False    |
| /mcollective | amq.topic             | topic   | False       | True    | False    |
| /mcollective | mcollective_broadcast | topic   | False       | True    | False    |
+--------------+-----------------------+---------+-------------+---------+----------+

Now add a mcollective section in rabbitMQ configuration file :

{rabbitmq_stomp,
 [
        {rabbitmq_stomp, [{tcp_listeners, [{"192.168.10.13", 61613},
                                             {"::1",       61613}]},
                          {default_user, [{login, "mcollective"},
                                             {passcode, "changeme"}]},
                         {implicit_connect, true}
                         ]
        }
 ]
},

Allow mcollective_reply :

# /etc/mcollective/server.cfg
plugin.rabbitmq.use_reply_exchange = true

...

# create exchange mcollective_reply on MASTER
rabbitmqadmin declare exchange --user=adminUser --password=adminPass --vhost=/mcollective name=mcollective_reply type=direct

# create an exchange named mcollective_directed
rabbitmqadmin declare exchange --user=adminUser --password=adminPass --vhost=/mcollective name=mcollective_directed type=direct

And that's all for RabbitMQ :)

MCollective

Master

First clone mcolelctive git repo, then install mcollective as this :

git clone https://github.com/puppetlabs/marionette-collective.git
cd marionette-collective/
./install.rb

And MCollective is installed but without an init script. So from the installation directory just type :

cp -a ext/debian/mcollective.init /etc/init.d/mcollective
chmod u+x /etc/init.d/mcollective
update-rc.d -f mcollective defaults # to start mcollective at boot time

Configure the server.cfg file to let mcollective daemon start :

main_collective = mcollective
 collectives = mcollective
 libdir = /usr/libexec/mcollective
 logfile = /var/log/mcollective.log
 loglevel = debug
 daemonize = 1

 # Plugins
 securityprovider = psk
 plugin.psk = unset

 direct_addressing = 1

 connector = rabbitmq
 plugin.rabbitmq.vhost = /mcollective
 plugin.rabbitmq.pool.size = 1
 plugin.rabbitmq.pool.1.host = 192.168.10.13
 plugin.rabbitmq.pool.1.port = 61613
 plugin.rabbitmq.pool.1.user = mcollective
 plugin.rabbitmq.pool.1.password = changeme
 plugin.rabbitmq.use_reply_exchange = true

 plugin.rabbitmq.initial_reconnect_delay = 0.01
 plugin.rabbitmq.max_reconnect_delay = 30.0
 plugin.rabbitmq.use_exponential_back_off = true
 plugin.rabbitmq.back_off_multiplier = 2
 plugin.rabbitmq.max_reconnect_attempts = 0
 plugin.rabbitmq.randomize = false
 plugin.rabbitmq.timeout = -1


 # Facts
 factsource = yaml
 plugin.yaml = /etc/mcollective/facts.yaml

and the client.cfg file :

main_collective = mcollective
collectives = mcollective
libdir = /usr/libexec/mcollective
logfile = /var/log/mcollective.log
loglevel = debug
daemonize = 1

securityprovider = psk
plugin.psk = unset


direct_addressing = 1

connector = rabbitmq
plugin.rabbitmq.vhost = /mcollective
plugin.rabbitmq.pool.size = 1
plugin.rabbitmq.pool.1.host = 192.168.10.13
plugin.rabbitmq.pool.1.port = 61613
plugin.rabbitmq.pool.1.user = mcollective
plugin.rabbitmq.pool.1.password = changeme

plugin.rabbitmq.initial_reconnect_delay = 0.01
plugin.rabbitmq.max_reconnect_delay = 30.0
plugin.rabbitmq.use_exponential_back_off = true
plugin.rabbitmq.back_off_multiplier = 2
plugin.rabbitmq.max_reconnect_attempts = 0
plugin.rabbitmq.randomize = false
plugin.rabbitmq.timeout = -1


factsource = yaml
plugin.yaml = /etc/mcollective/facts.yaml

Slave

Same process as for the master ! Easy no ?

Test

Just try a ping and let's see what appened :

mco ping
vm-mco-master                            time=67.39 ms
vm-mco-agent                             time=68.20 ms


---- ping statistics ----
2 replies max: 68.20 min: 67.39 avg: 67.80

It works fine :)

Next step is to install plugins to perform actions, this will be in another post, be patient ...

Puppet

Puppet is deployed in a standalone mode, which seems to be the best way to manage puppet with mcollective. To share puppet configuration directory, it is possible to user FS like :

- GlusterFS
- Sheepdog
- MooseFS

Also it is possible to use softwares like :

- Pacemaker
- Corosync

This part of puppet deployment way will be treated in another post, so be patient.

Comments !