try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / nova / manifests / rabbitmq.pp
1 # == Class: nova::rabbitmq
2 #
3 # Installs and manages rabbitmq server for nova
4 #
5 # == Parameters:
6 #
7 # [*userid*]
8 #   (optional) The username to use when connecting to Rabbit
9 #   Defaults to 'guest'
10 #
11 # [*password*]
12 #   (optional) The password to use when connecting to Rabbit
13 #   Defaults to 'guest'
14 #
15 # [*port*]
16 #   (optional) The port to use when connecting to Rabbit
17 #   Defaults to '5672'
18 #
19 # [*virtual_host*]
20 #   (optional) The virtual host to use when connecting to Rabbit
21 #   Defaults to '/'
22 #
23 # [*cluster_disk_nodes*]
24 #   (optional) Enables/disables RabbitMQ clustering.  Specify an array of Rabbit Broker
25 #   IP addresses to configure clustering.
26 #   Defaults to false
27 #
28 # [*enabled*]
29 #   (optional) Whether to enable the Rabbit service
30 #   Defaults to false
31 #
32 # [*rabbitmq_class*]
33 #   (optional) The rabbitmq puppet class to depend on,
34 #   which is dependent on the puppet-rabbitmq version.
35 #   Use the default for 1.x, use 'rabbitmq' for 3.x
36 #   Defaults to 'rabbitmq::server'
37 #
38 class nova::rabbitmq(
39   $userid             ='guest',
40   $password           ='guest',
41   $port               ='5672',
42   $virtual_host       ='/',
43   $cluster_disk_nodes = false,
44   $enabled            = true,
45   $rabbitmq_class     = 'rabbitmq::server'
46 ) {
47
48   # only configure nova after the queue is up
49   Class[$rabbitmq_class] -> Anchor<| title == 'nova-start' |>
50
51   if ($enabled) {
52     if $userid == 'guest' {
53       $delete_guest_user = false
54     } else {
55       $delete_guest_user = true
56       rabbitmq_user { $userid:
57         admin     => true,
58         password  => $password,
59         provider  => 'rabbitmqctl',
60         require   => Class[$rabbitmq_class],
61       }
62       # I need to figure out the appropriate permissions
63       rabbitmq_user_permissions { "${userid}@${virtual_host}":
64         configure_permission => '.*',
65         write_permission     => '.*',
66         read_permission      => '.*',
67         provider             => 'rabbitmqctl',
68       }->Anchor<| title == 'nova-start' |>
69     }
70     $service_ensure = 'running'
71   } else {
72     $service_ensure = 'stopped'
73   }
74
75   if $cluster_disk_nodes {
76     class { $rabbitmq_class:
77       service_ensure           => $service_ensure,
78       port                     => $port,
79       delete_guest_user        => $delete_guest_user,
80       config_cluster           => true,
81       cluster_disk_nodes       => $cluster_disk_nodes,
82       wipe_db_on_cookie_change => true,
83     }
84   } else {
85     class { $rabbitmq_class:
86       service_ensure    => $service_ensure,
87       port              => $port,
88       delete_guest_user => $delete_guest_user,
89     }
90   }
91
92   if ($enabled) {
93     rabbitmq_vhost { $virtual_host:
94       provider => 'rabbitmqctl',
95       require  => Class[$rabbitmq_class],
96     }
97   }
98 }