puppet连载21:搭建rabbitmq

简介: rabbitmq 3.6.6cd /puppet/softwget http://www.rabbitmq.com/releases/erlang/erlang-19.

rabbitmq 3.6.6

cd /puppet/soft
wget http://www.rabbitmq.com/releases/erlang/erlang-19.0.4-1.el7.centos.x86_64.rpm
wget http://www.rabbitmq.com/releases/rabbitmq-server/v3.6.6/rabbitmq-server-3.6.6-1.el7.noarch.rpm
wget http://www.rabbitmq.com/rabbitmq-signing-key-public.asc
mkdir -p /etc/puppet/modules/linuxrabbitmq/{manifests,files,templates}


写配置文件

vi /etc/puppet/modules/linuxrabbitmq/templates/rabbitmq-env-3.6.6.conf.erb

RABBITMQ_NODE_IP_ADDRESS=0.0.0.0

RABBITMQ_NODE_PORT=<%= real_rabbitmq_port %>

RABBITMQ_NODENAME=<%= real_rabbitmq_name %>

RABBITMQ_CONFIG_FILE="/etc/rabbitmq/rabbitmq.conf"

RABBITMQ_MNESIA_BASE="/var/lib/rabbitmq/mnesia"

RABBITMQ_LOG_BASE="/var/log"

RABBITMQ_PLUGINS_DIR="/usr/lib/rabbitmq/lib/rabbitmq_server-3.6.6/plugins"


cp /usr/share/doc/rabbitmq-server-3.6.6/rabbitmq.config.example /etc/puppet/modules/linuxrabbitmq/templates/rabbitmq-3.6.6.conf.erb

vim /etc/puppet/modules/linuxrabbitmq/manifests/init.pp
class linuxrabbitmq::rabbitmq366 {

real_rabbitmq_port=rabbitmq_port ? { '' => '5672',default => rabbitmq_port }real_rabbitmq_mana_port=rabbitmq_mana_port ? { '' => '15672',default =>rabbitmq_mana_port }
real_rabbitmq_erl_port=rabbitmq_erl_port ? { '' => '25672',default => rabbitmq_erl_port }real_rabbitmq_name=rabbitmq_name ? { '' => 'rabbitmq@fqdn',default => $rabbitmq_name }

file {"/usr/local/src/erlang-19.0.4-1.el7.centos.x86_64.rpm":
source => "puppet:///soft/erlang-19.0.4-1.el7.centos.x86_64.rpm",
ensure => file,
mode => 755,owner => root,group => root,
notify => Exec["rpm erlang-19.0.4-1.el7.centos.x86_64.rpm"],
}
file {"/usr/local/src/rabbitmq-server-3.6.6-1.el7.noarch.rpm":
source => "puppet:///soft/rabbitmq-server-3.6.6-1.el7.noarch.rpm",
ensure => file,
mode => 755,owner => root,group => root,
notify => Exec["yum rabbitmq-server-3.6.6-1.el7.noarch.rpm"],
require => File["/usr/local/src/rabbitmq-signing-key-public.asc"],
}
file {"/usr/local/src/rabbitmq-signing-key-public.asc":
source => "puppet:///soft/rabbitmq-signing-key-public.asc",
ensure => file,
mode => 755,owner => root,group => root,
notify => Exec["rpm rabbitmq-signing-key-public.asc"],
require => File["/usr/local/src/erlang-19.0.4-1.el7.centos.x86_64.rpm"],
}
exec {"rpm erlang-19.0.4-1.el7.centos.x86_64.rpm":
command => "rpm -ivh erlang-19.0.4-1.el7.centos.x86_64.rpm",
path => ["/usr/bin","/usr/sbin","/sbin","/bin"],
cwd => "/usr/local/src",
refreshonly => true,
}
exec {"rpm rabbitmq-signing-key-public.asc":
command => "rpm --import rabbitmq-signing-key-public.asc",
path => ["/usr/bin","/usr/sbin","/sbin","/bin"],
cwd => "/usr/local/src",
refreshonly => true,
}
exec {"yum rabbitmq-server-3.6.6-1.el7.noarch.rpm":
command => "yum -y install rabbitmq-server-3.6.6-1.el7.noarch.rpm",
path => ["/usr/bin","/usr/sbin","/sbin","/bin"],
cwd => "/usr/local/src",
refreshonly => true,
before => Service["rabbitmq-server"],
}
exec {"firewallrabbitmqport":
command => "firewall-cmd --add-port real_rabbitmq_port/tcp --permanent && firewall-cmd --add-portreal_rabbitmq_mana_port/tcp --permanent && firewall-cmd --add-port real_rabbitmq_erl_port/tcp --permanent && firewall-cmd --reload", path => ["/usr/sbin","/usr/bin","/bin","/sbin"], provider => shell, unless => "firewall-cmd --list-port|tr ' ' '\n'|grep 'real_rabbitmq_port/tcp'",
}
service {"rabbitmq-server":
ensure => running,
enable => true,
}
exec {"rabbitmq_management":
command => "rabbitmq-plugins enable rabbitmq_management&&rabbitmqctl add_user root root&&rabbitmqctl set_user_tags root administrator&&rabbitmqctl set_permissions -p / root '.' '.' '.*'",
path => ["/usr/sbin","/usr/bin","/bin","/sbin"],
require => Service["rabbitmq-server"],
unless => "rabbitmqctl list_users|grep root",
}
file {'/etc/rabbitmq/rabbitmq-env.conf':
ensure => file,
mode => 755,owner => root,group => root,
content => template("/etc/puppet/modules/linuxrabbitmq/templates/rabbitmq-env-3.6.6.conf.erb"),
backup => '.bak',
notify => Service["rabbitmq-server"],
require => Exec["yum rabbitmq-server-3.6.6-1.el7.noarch.rpm"],
}
file {'/etc/rabbitmq/rabbitmq.conf':
ensure => file,
mode => 755,owner => root,group => root,
content => template("/etc/puppet/modules/linuxrabbitmq/templates/rabbitmq-3.6.6.conf.erb"),
backup => '.bak',
notify => Service["rabbitmq-server"],
require => Exec["yum rabbitmq-server-3.6.6-1.el7.noarch.rpm"],
}
}


调用

node 'huangat-test' {
rabbitmq_port = 5672rabbitmq_mana_port = 15672
$rabbitmq_erl_port = 25672
include linuxrabbitmq::rabbitmq366
}


相关实践学习
消息队列RocketMQ版:基础消息收发功能体验
本实验场景介绍消息队列RocketMQ版的基础消息收发功能,涵盖实例创建、Topic、Group资源创建以及消息收发体验等基础功能模块。
消息队列 MNS 入门课程
1、消息队列MNS简介 本节课介绍消息队列的MNS的基础概念 2、消息队列MNS特性 本节课介绍消息队列的MNS的主要特性 3、MNS的最佳实践及场景应用 本节课介绍消息队列的MNS的最佳实践及场景应用案例 4、手把手系列:消息队列MNS实操讲 本节课介绍消息队列的MNS的实际操作演示 5、动手实验:基于MNS,0基础轻松构建 Web Client 本节课带您一起基于MNS,0基础轻松构建 Web Client
目录
相关文章
|
5月前
|
消息中间件 数据可视化 大数据
【如何安装和配置RabbitMQ(转载)】
【如何安装和配置RabbitMQ(转载)】
69 2
|
2月前
|
消息中间件 Docker 容器
消息中间件RabbitMQ---Docker安装RabbitMQ、以及RabbitMQ的基本使用【二】
这篇文章提供了RabbitMQ的安装和基本使用教程,包括如何使用Docker拉取RabbitMQ镜像、创建容器、通过浏览器访问管理界面,以及如何创建交换机、队列、绑定和使用direct、fanout和topic三种类型的交换器进行消息发布和接收的测试。
消息中间件RabbitMQ---Docker安装RabbitMQ、以及RabbitMQ的基本使用【二】
|
2月前
|
消息中间件 Ubuntu 安全
如何安装和管理RabbitMQ
如何安装和管理RabbitMQ
38 0
|
2月前
|
消息中间件 监控 数据可视化
安装部署RabbitMQ
安装部署RabbitMQ
|
5月前
|
消息中间件 Linux
RabbitMq 安装部署
RabbitMq 安装部署
|
消息中间件 数据安全/隐私保护 Docker
RabbitMQ详解(二):Docker安装RabbitMQ
RabbitMQ详解(二):Docker安装RabbitMQ
1278 0
|
消息中间件 数据安全/隐私保护
rabbitMq详细安装部署
今天给大家介绍一下rabbitMq的详细安装教程
124 0
rabbitMq详细安装部署
|
消息中间件 网络安全 数据安全/隐私保护
【安装配置RabbitMQ】
【安装配置RabbitMQ】
109 0
【安装配置RabbitMQ】
|
消息中间件 开发工具 C语言
RabbitMQ系列(一)--------安装配置
安装RabbitMQ 前提先要配置好环境 需要先安装Erlang
93 0
RabbitMQ系列(一)--------安装配置
|
消息中间件 数据安全/隐私保护
RabbitMq(一)安装使用
RabbitMq(一)安装使用
132 0

推荐镜像

更多