systemadmin.es > Gestión de cofiguración > Instalar mcollective con ActiveMQ en CentOS 6

Instalar mcollective con ActiveMQ en CentOS 6

Vamos a ver cómo instalar el agente y cliente de mcollective con ActiveMQ en CentOS 6

Primero instalamos ActiveMQ y mcollective:

yum install activemq mcollective

Modificamos el fichero de configuración (/etc/activemq/activemq.xml) con los usuarios que necesitemos:

cat <<"EOF" > /etc/activemq/activemq.xml
<beans
  xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
        http://activemq.apache.org/schema/core http://activemq.apache.org/schema/core/activemq-core.xsd">

    <!-- Allows us to use system properties as variables in this configuration file -->
    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
            <property name="locations">
                        <value>file:${activemq.conf}/credentials.properties</value>
            </property>
    </bean>

    <broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}">

        <destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" producerFlowControl="false"/>
                <policyEntry queue="*.reply.>" gcInactiveDestinations="true" inactiveTimoutBeforeGC="300000"/>
              </policyEntries>
            </policyMap>
        </destinationPolicy>

        <managementContext>
            <managementContext createConnector="false"/>
        </managementContext>

        <persistenceAdapter>
            <kahaDB directory="${activemq.data}/kahadb"/>
        </persistenceAdapter>


        <plugins>
          <statisticsBrokerPlugin/>
          <simpleAuthenticationPlugin>
            <users>
              <authenticationUser username="mcollective" password="userpassword" groups="mcollective,everyone"/>
              <authenticationUser username="admin" password="adminpassword" groups="mcollective,admins,everyone"/>
            </users>
          </simpleAuthenticationPlugin>
          <authorizationPlugin>
            <map>
              <authorizationMap>
                <authorizationEntries>
                  <authorizationEntry queue=">" write="admins" read="admins" admin="admins"/>
                  <authorizationEntry topic=">" write="admins" read="admins" admin="admins"/>
                  <authorizationEntry queue="mcollective.>" write="mcollective" read="mcollective" admin="mcollective"/>
                  <authorizationEntry topic="mcollective.>" write="mcollective" read="mcollective" admin="mcollective"/>
                  <authorizationEntry topic="ActiveMQ.Advisory.>" read="everyone" write="everyone" admin="everyone"/>
                </authorizationEntries>
              </authorizationMap>
            </map>
          </authorizationPlugin>
        </plugins>

        <systemUsage>
            <systemUsage>
                <memoryUsage>
                    <memoryUsage limit="20 mb"/>
                </memoryUsage>
                <storeUsage>
                    <storeUsage limit="1 gb"/>
                </storeUsage>
                <tempUsage>
                    <tempUsage limit="100 mb"/>
                </tempUsage>
            </systemUsage>
        </systemUsage>

        <transportConnectors>
            <transportConnector name="openwire" uri="tcp://0.0.0.0:6166"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:6163"/>
        </transportConnectors>
    </broker>

    <import resource="jetty.xml"/>
</beans>
EOF

Reiniciamos ActiveMQ para aplicar la configuración:

/etc/init.d/activemq restart

Finalmente configuraremos el cliente de mcollective mediante el fichero /etc/mcollective/client.cfg que deberemos modificar con los datos necesarios (psk, usuario, contraseña y host del ActiveMQ):

main_collective = mcollective
collectives = mcollective
libdir = /usr/libexec/mcollective
logger_type = console
loglevel = warn

# Plugins
securityprovider = psk
plugin.psk = viscacatalunyalliure

connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = localhost
plugin.activemq.pool.1.port = 6163
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = userpassword

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

En los agentes que configuraremos en todos los hosts que queremos administrar deberemos configurar el fichero /etc/mcollective/server.cfg (igualmente psk, usuario, contraseña y host):

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

# Plugins
securityprovider = psk
plugin.psk = viscacatalunyalliure

connector = activemq
plugin.activemq.pool.size = 1
plugin.activemq.pool.1.host = puppetserver
plugin.activemq.pool.1.port = 6163
plugin.activemq.pool.1.user = mcollective
plugin.activemq.pool.1.password = userpassword


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

Arrancamos el agente con:

/etc/init.d/mcollective restart

Dicho comando no es necesario en el host que tengamos el cliente.

Deja un comentario:

XHTML - Tags permitidos:<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>