From 63917a52940634e591fe2ddde41eb5f2b95c39cc Mon Sep 17 00:00:00 2001 From: Jeff McCune Date: Tue, 22 Mar 2011 10:39:23 -0700 Subject: [PATCH] Add rabbitmq service class. This class manages the rabbitmq package, configuration file for Stomp and the running service. I need to add two defined resource types to manage the user accounts in RabbitMQ and install additional plugins. --- deployment/puppet/rabbitmq/manifests/init.pp | 33 +++++++++++++++- .../puppet/rabbitmq/manifests/params.pp | 38 +++++++++++++++++++ .../puppet/rabbitmq/templates/rabbitmq.conf | 2 + deployment/puppet/rabbitmq/tests/site.pp | 8 ++++ 4 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 deployment/puppet/rabbitmq/manifests/params.pp create mode 100644 deployment/puppet/rabbitmq/templates/rabbitmq.conf create mode 100644 deployment/puppet/rabbitmq/tests/site.pp diff --git a/deployment/puppet/rabbitmq/manifests/init.pp b/deployment/puppet/rabbitmq/manifests/init.pp index 042c90bdb0..6d98ef5ee3 100644 --- a/deployment/puppet/rabbitmq/manifests/init.pp +++ b/deployment/puppet/rabbitmq/manifests/init.pp @@ -11,7 +11,38 @@ # Sample Usage: # # [Remember: No empty lines between comments and class definition] -class rabbitmq { +class rabbitmq($config='UNSET') inherits rabbitmq::params { + if $config == 'UNSET' { + $config_real = template("${module_name}/rabbitmq.conf") + } else { + $config_real = $config + } + + File { + owner => '0', + group => '0', + mode => '0644', + } + + package { $packages: + ensure => $pkg_ensure, + notify => Service["${service}"], + before => File['rabbitmq.conf'], + } + + file { 'rabbitmq.conf': + ensure => file, + path => '/etc/rabbitmq/rabbitmq.conf', + content => $config_real, + notify => Service["${service}"], + } + + service { $service: + ensure => running, + enable => true, + hasstatus => true, + hasrestart => true, + } } diff --git a/deployment/puppet/rabbitmq/manifests/params.pp b/deployment/puppet/rabbitmq/manifests/params.pp new file mode 100644 index 0000000000..ba1bde318c --- /dev/null +++ b/deployment/puppet/rabbitmq/manifests/params.pp @@ -0,0 +1,38 @@ +# Class: rabbitmq::params +# +# This class provides parameters for the rabbitmq module. +# +# Jeff McCune +# +# The intention is to subclass this class to bring the variables into scope. +# +# Parameters: +# +# version: 2.3.1 +# +# Actions: +# +# Requires: +# +# Sample Usage: +# +# class rabbitmq inherits rabbitmq::params { } +# +class rabbitmq::params( + $version = 'UNSET' +) { + + # This is the RabbitMQ Server Version + if $version == 'UNSET' { + $version_real = '2.3.1-1' + $pkg_ensure = 'present' + } else { + $version_real = $version + $pkg_ensure = $version + } + + $packages = [ 'rabbitmq-server' ] + $service = 'rabbitmq-server' + +} + diff --git a/deployment/puppet/rabbitmq/templates/rabbitmq.conf b/deployment/puppet/rabbitmq/templates/rabbitmq.conf new file mode 100644 index 0000000000..04d1f5f0f7 --- /dev/null +++ b/deployment/puppet/rabbitmq/templates/rabbitmq.conf @@ -0,0 +1,2 @@ +# This file managed by Puppet +SERVER_START_ARGS="-rabbit_stomp tcp_listeners [6163]" diff --git a/deployment/puppet/rabbitmq/tests/site.pp b/deployment/puppet/rabbitmq/tests/site.pp new file mode 100644 index 0000000000..7b86e22b86 --- /dev/null +++ b/deployment/puppet/rabbitmq/tests/site.pp @@ -0,0 +1,8 @@ +node default { + + class { 'rabbitmq': + config => template('rabbitmq/rabbitmq.conf'), + } + +} +