Skip to content
Browse files

Initial version

  • Loading branch information...
0 parents commit 84e1df1700d9b60f69fe3a0ffd8680504cc81728 @athak athak committed Jan 15, 2011
3 README
@@ -0,0 +1,3 @@
+rabbitmq
+
+This is the rabbitmq module.
1 files/rabbitmq.conf
@@ -0,0 +1 @@
+SERVER_START_ARGS="-rabbit_stomp listeners [{\"0.0.0.0\",6163}]"
11 manifests/classes/config.pp
@@ -0,0 +1,11 @@
+# Class: rabbitmq::config
+#
+#
+class rabbitmq::config {
+ File {
+ require => Class["rabbitmq::install::${rabbitmq::install_class}"],
+ notify => Class["rabbitmq::service"],
+ owner => root,
+ group => root
+ }
+}
8 manifests/classes/install/debian.pp
@@ -0,0 +1,8 @@
+# Class: rabbitmq::install::debian
+#
+#
+class rabbitmq::install::debian {
+ package { "rabbitmq-server":
+ ensure => latest
+ }
+}
33 manifests/classes/install/redhat.pp
@@ -0,0 +1,33 @@
+# Class: rabbitmq::install::redhat
+#
+#
+class rabbitmq::install::redhat {
+ # Fetch the updated RPM from rabbitmq.com
+ common::archive::download { "rabbitmq-server-${rabbitmq_version}-1.noarch.rpm":
+ ensure => present,
+ checksum => false,
+ url => "http://www.rabbitmq.com/releases/rabbitmq-server/v${rabbitmq_version}/rabbitmq-server-${rabbitmq_version}-1.noarch.rpm"
+ }
+
+ # Fetch the GPG key only if we don't have it
+ exec { "fetch-rabbitmq-gpg-key":
+ command => "/usr/bin/wget -q http://www.rabbitmq.com/rabbitmq-signing-key-public.asc",
+ cwd => "/tmp",
+ unless => "/bin/rpm -qi gpg-pubkey-* | /bin/grep RabbitMQ",
+ notify => Exec["import-rabbitmq-gpg-key"]
+ }
+
+ exec { "import-rabbitmq-gpg-key":
+ command => "/bin/rpm --import /tmp/rabbitmq-signing-key-public.asc",
+ cwd => "/tmp",
+ refreshonly => true,
+ require => Exec["fetch-rabbitmq-gpg-key"]
+ }
+
+ # Tell yum to install the downloaded file
+ yum::localinstall { "rabbitmq-server":
+ file => "/usr/src/rabbitmq-server-${rabbitmq_version}-1.noarch.rpm",
+ provides => "rabbitmq-server",
+ require => [ Common::Archive::Download["rabbitmq-server-${rabbitmq_version}-1.noarch.rpm"], Exec["import-rabbitmq-gpg-key"] ]
+ }
+}
24 manifests/classes/mcollective.pp
@@ -0,0 +1,24 @@
+# Class: rabbitmq::mcollective
+#
+#
+class rabbitmq::mcollective {
+ include rabbitmq
+
+ rabbitmq::plugin { "amqp_client":
+ ensure => present,
+ require => Class["rabbitmq::install::${rabbitmq::install_class}"]
+ }
+
+ rabbitmq::plugin { "rabbit_stomp":
+ ensure => present,
+ require => Class["rabbitmq::install::${rabbitmq::install_class}"]
+ }
+
+ file { "/etc/rabbitmq/rabbitmq.conf":
+ ensure => present,
+ source => "puppet:///modules/rabbitmq/rabbitmq.conf",
+ mode => 644,
+ notify => Class["rabbitmq::service"],
+ require => [ Class["rabbitmq::install::${rabbitmq::install_class}"], Rabbitmq::Plugin["amqp_client"], Rabbitmq::Plugin["rabbit_stomp"] ]
+ }
+}
11 manifests/classes/service.pp
@@ -0,0 +1,11 @@
+# Class: rabbitmq::service
+#
+#
+class rabbitmq::service {
+ service { "rabbitmq-server":
+ ensure => running,
+ enable => true,
+ hasstatus => true,
+ require => Class["rabbitmq::config"]
+ }
+}
22 manifests/definitions/permissions.pp
@@ -0,0 +1,22 @@
+# Define: rabbitmq::permissions
+# Parameters:
+# arguments
+#
+define rabbitmq::permissions ($ensure = present, $vhost = '/', $conf = '.*', $read = '.*', $write = '.*') {
+ require rabbitmq
+
+ case $ensure {
+ present: {
+ exec{ "rabbitmqctl-permissions-$name":
+ command => "rabbitmqctl set_permissions -p '$vhost' '$name' '$conf' '$write' '$read'",
+ onlyif => "test `rabbitmqctl -q list_permissions -p '$vhost' | grep '^$name\t$conf\t$write\t$read' | wc -l` -eq 0",
+ }
+ }
+ absent: {
+ exec{ "rabbitmqctl-permissions-$name":
+ command => "rabbitmqctl clear_permissions -p '$vhost' '$name'",
+ onlyif => "test `rabbitmqctl -q list_permissions -p '$vhost' | grep '^$name\t$conf\t$write\t$read ' | wc -l` -gt 0",
+ }
+ }
+ }
+}
16 manifests/definitions/plugin.pp
@@ -0,0 +1,16 @@
+# Define: rabbitmq::plugin
+# Parameters:
+# $ensure=present
+# $url="www.rabbitmq.com/releases/plugins"
+# $version="2.2.0"
+# $target="/usr/lib/rabbitmq/lib/rabbitmq_server-version/plugins"
+#
+define rabbitmq::plugin ($ensure=present, $url="www.rabbitmq.com/releases/plugins", $version="2.2.0", $target="/usr/lib/rabbitmq/lib/rabbitmq_server-${version}/plugins") {
+ common::archive::download { "${name}.ez":
+ ensure => $ensure,
+ checksum => false,
+ url => "http://${url}/v${version}/${name}-${version}.ez",
+ src_target => $target,
+ notify => Class["rabbitmq::service"]
+ }
+}
38 manifests/definitions/user.pp
@@ -0,0 +1,38 @@
+# Define: rabbitmq::user
+# Parameters:
+# $ensure = present,
+# $password = false,
+# $vhost = '/',
+# $conf = '.*',
+# $read = '.*',
+# $write = '.*'
+#
+define rabbitmq::user ($ensure = present, $password = false, $vhost = '/', $conf = '.*', $read = '.*', $write = '.*') {
+ require rabbitmq
+
+ case $ensure {
+ present: {
+ if ! $password {
+ fail "Must pass password to rabbitmq::user"
+ }
+ exec{ "rabbitmqctl-user-$name":
+ command => "rabbitmqctl add_user '$name' '$password'",
+ onlyif => "test `rabbitmqctl -q list_users | grep '^$name\t' | wc -l` -eq 0",
+ }
+ }
+ absent: {
+ exec{ "rabbitmqctl-user-$name":
+ command => "rabbitmqctl delete_user '$name'",
+ onlyif => "test `rabbitmqctl -q list_users | grep '^$name\t' | wc -l` -gt 0",
+ }
+ }
+ }
+
+ rabbitmq::permissions{$name:
+ ensure => $ensure,
+ vhost => $vhost,
+ conf => $conf,
+ read => $read,
+ write => $write,
+ }
+}
24 manifests/init.pp
@@ -0,0 +1,24 @@
+import "classes/*.pp"
+import "classes/install/*.pp"
+import "definitions/*.pp"
+
+# Class: rabbitmq
+#
+#
+class rabbitmq {
+ if ( ! $rabbitmq_version ) { $rabbitmq_version = "2.2.0" }
+
+ case $operatingsystem {
+ /(?i)(Debian|Ubuntu)/: {
+ $install_class = "debian"
+ }
+ /(?i)(Redhat|CentOS)/: {
+ $install_class = "redhat"
+ }
+ default: {
+ fail "Unsupported OS ${operatingsystem} in 'rabbitmq' module"
+ }
+ }
+
+ include "rabbitmq::install::${install_class}", rabbitmq::config, rabbitmq::service
+}
6 metadata.json
@@ -0,0 +1,6 @@
+{
+ "license": "GPL2",
+ "author": "Vurbia Technologies International Inc.",
+ "version": "1.0",
+ "source": "http://github.com/vurbia/puppet-rabbitmq/"
+}
1 tests/init.pp
@@ -0,0 +1 @@
+include rabbitmq

0 comments on commit 84e1df1

Please sign in to comment.
Something went wrong with that request. Please try again.