Search code examples
rubyrubygemsrabbitmqpuppetmcollective

Using RabbitMQ connector for MCollective


Here's my client.cfg file:

main_collective = mcollective
collectives = mcollective
libdir = /usr/share/mcollective/plugins
logger_type = console
loglevel = warn

# Plugins
securityprovider = psk
plugin.psk = unset

connector = rabbitmq 
plugin.rabbitmq.pool.size = 1
plugin.rabbitmq.pool.1.host = myserver 
plugin.rabbitmq.pool.1.port = 61613 
plugin.rabbitmq.pool.1.user = guest
plugin.rabbitmq.pool.1.password = password

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

I have set up RabbitMQ server on my Puppet Master server. RabbitMQ is configured correctly as far as I know. The ports are open and it is ready to accept connections.

On MCollective client I am getting the following error:

mco ping -v

=> debug 2015/07/17 15:10:54: pluginmanager.rb:167:in `loadclass' Loading
=> Mcollective::Facts::Yaml_facts from mcollective/facts/yaml_facts.rb
=> debug 2015/07/17 15:10:54: pluginmanager.rb:44:in `<<' Registering
=> plugin facts_plugin with class MCollective::Facts::Yaml_facts
=> single_instance: true debug 2015/07/17 15:10:54:
=> pluginmanager.rb:167:in `loadclass' Loading
=> Mcollective::Connector::Rabbitmq from
=> mcollective/connector/rabbitmq.rb debug 2015/07/17 15:10:54:
=> cache.rb:117:in `block in ttl' Cache miss on 'ddl' key
=> 'connector/rabbitmq' debug 2015/07/17 15:10:54: base.rb:94:in `block
=> in findddlfile' Found rabbitmq ddl at
=> /usr/local/lib/site_ruby/1.9.1/mcollective/connector/rabbitmq.ddl
=> debug 2015/07/17 15:10:54: pluginmanager.rb:44:in `<<' Registering
=> plugin connector_plugin with class MCollective::Connector::Rabbitmq
=> single_instance: true debug 2015/07/17 15:10:54:
=> pluginmanager.rb:167:in `loadclass' Loading Mcollective::Security::Psk
=> from mcollective/security/psk.rb debug 2015/07/17 15:10:54:
=> pluginmanager.rb:44:in `<<' Registering plugin security_plugin with
=> class MCollective::Security::Psk single_instance: true debug
=> 2015/07/17 15:10:54: pluginmanager.rb:167:in `loadclass' Loading
=> Mcollective::Registration::Agentlist from
=> mcollective/registration/agentlist.rb debug 2015/07/17 15:10:54:
=> pluginmanager.rb:44:in `<<' Registering plugin registration_plugin
=> with class MCollective::Registration::Agentlist single_instance: true
=> debug 2015/07/17 15:10:54: pluginmanager.rb:47:in `<<' Registering
=> plugin global_stats with class MCollective::RunnerStats
=> single_instance: true info 2015/07/17 15:10:54: config.rb:167:in
=> `loadconfig' The Marionette Collective version 2.8.2 started by
=> /usr/bin/mco using config file /etc/mcollective/client.cfg debug
=> 2015/07/17 15:10:54: pluginmanager.rb:167:in `loadclass' Loading
=> MCollective::Application::Ping from mcollective/application/ping.rb
=> debug 2015/07/17 15:10:54: pluginmanager.rb:44:in `<<' Registering
=> plugin ping_application with class MCollective::Application::Ping
=> single_instance: true debug 2015/07/17 15:10:54:
=> pluginmanager.rb:80:in `[]' Returning new plugin ping_application with
=> class MCollective::Application::Ping debug 2015/07/17 15:10:54:
=> pluginmanager.rb:80:in `[]' Returning new plugin connector_plugin with
=> class MCollective::Connector::Rabbitmq info 2015/07/17 15:10:54:
=> rabbitmq.rb:106:in `initialize' RabbitMQ connector initialized.  Using
=> stomp-gem 1.3.2 debug 2015/07/17 15:10:54: pluginmanager.rb:80:in `[]'
=> Returning new plugin security_plugin with class
=> MCollective::Security::Psk debug 2015/07/17 15:10:54:
=> pluginmanager.rb:83:in `[]' Returning cached plugin global_stats with
=> class MCollective::RunnerStats debug 2015/07/17 15:10:54:
=> rabbitmq.rb:136:in `block in connect' Adding
=> server:61613 to the connection pool
=> info 2015/07/17 15:10:54: rabbitmq.rb:201:in `connection_headers'
=> Connecting without STOMP 1.1 heartbeats, consider setting
=> plugin.rabbitmq.heartbeat_interval info 2015/07/17 15:10:54:
=> rabbitmq.rb:10:in `on_connecting' TCP Connection attempt 0 to
=> stomp://server:61613 info
=> 2015/07/17 15:10:54: rabbitmq.rb:15:in `on_connected' Connected to
=> stomp://guest@server:61613 debug
=> 2015/07/17 15:10:54: pluginmanager.rb:83:in `[]' Returning cached
=> plugin security_plugin with class MCollective::Security::Psk debug
=> 2015/07/17 15:10:54: base.rb:178:in `create_request' Encoding a
=> request for agent 'discovery' in collective mcollective with request
=> id c93c6c5c19ed5a96abaa93eb2da8e6b1 debug 2015/07/17 15:10:54:
=> psk.rb:98:in `callerid' Setting callerid to uid=0 based on
=> callertype=uid debug 2015/07/17 15:10:54: client.rb:96:in `subscribe'
=> Subscribing to reply target for agent discovery debug 2015/07/17
=> 15:10:54: pluginmanager.rb:83:in `[]' Returning cached plugin
=> connector_plugin with class MCollective::Connector::Rabbitmq debug
=> 2015/07/17 15:10:54: client.rb:225:in `start_publisher' Starting
=> publishing with publish timeout of  debug 2015/07/17 15:10:54:
=> client.rb:228:in `block in start_publisher' Sending request
=> c93c6c5c19ed5a96abaa93eb2da8e6b1 to the discovery agent with ttl 60 in
=> collective mcollective debug 2015/07/17 15:10:54:
=> pluginmanager.rb:83:in `[]' Returning cached plugin connector_plugin
=> with class MCollective::Connector::Rabbitmq debug 2015/07/17 15:10:54:
=> rabbitmq.rb:332:in `publish' Sending a broadcast message to RabbitMQ
=> target '/exchange/mcollective_broadcast/discovery' with headers
=> '{"reply-to"=>"/temp-queue/mcollective_reply_discovery",
=> "expiration"=>"70000", "mc_sender"=>"ubuntu"}' debug 2015/07/17
=> 15:10:54: client.rb:239:in `start_receiver' Starting response receiver
=> with timeout of 5 debug 2015/07/17 15:10:54: rabbitmq.rb:287:in
=> `receive' Waiting for a message from RabbitMQ debug 2015/07/17
=> 15:10:54: rabbitmq.rb:309:in `receive' Unexpected 'ERROR' frame.
=> Headers: {"message"=>"AMQP channel died",
=> "content-type"=>"text/plain", "version"=>"1.0,1.1,1.2",
=> "content-length"=>"144"} Body: "Reason: {shutdown,\n
=> {server_initiated_close,404,\n                <<\"NOT_FOUND - no
=> exchange 'mcollective_broadcast' in vhost '/'\">>}}" debug 2015/07/17
=> 15:10:54: client.rb:106:in `unsubscribe' Unsubscribing reply target
=> for discovery debug 2015/07/17 15:10:54: pluginmanager.rb:83:in `[]'
=> Returning cached plugin connector_plugin with class
=> MCollective::Connector::Rabbitmq
=>
=> The ping application failed to run: Received frame of type 'ERROR'
=> expected 'MESSAGE'
=>
=> Received frame of type 'ERROR' expected 'MESSAGE'
=> (MCollective::UnexpectedMessageType)  from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/connector/rabbitmq.rb:310:in
=> `receive'  <----  from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/client.rb:122:in `receive'
=>   from /usr/local/lib/site_ruby/1.9.1/mcollective/client.rb:244:in
=> `block in start_receiver'   from /usr/lib/ruby/1.9.1/timeout.rb:69:in
=> `timeout'   from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/client.rb:242:in
=> `start_receiver'  from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/client.rb:197:in
=> `unthreaded_req'  from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/client.rb:183:in `req'
=>   from
=> /usr/share/mcollective/plugins/mcollective/application/ping.rb:58:in
=> `main'  from
=> /usr/local/lib/site_ruby/1.9.1/mcollective/application.rb:293:in `run'
=>   from /usr/local/lib/site_ruby/1.9.1/mcollective/applications.rb:23:in
=> `run'   from /usr/bin/mco:20:in `<main>' debug 2015/07/17 15:10:54:
=> pluginmanager.rb:83:in `[]' Returning cached plugin connector_plugin
=> with class MCollective::Connector::Rabbitmq debug 2015/07/17 15:10:54:
=> rabbitmq.rb:449:in `disconnect' Disconnecting from RabbitMQ info
=> 2015/07/17 15:10:54: rabbitmq.rb:20:in `on_disconnect' Disconnected
=> from stomp://guest@server:61613

How do I fix the error for RabbitMQ connector?

Thanks!


Solution

  • The reason I wasn't able to connect was the exchange types were not setup. The following has to be done on the RabbitMQ server. Assuming you have your users setup.

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

    Enable use reply exchange on MCollective client (client.cfg):

    plugin.rabbitmq.use_reply_exchange = true