try again, with puppetforge modules, correctly included now
[mirror/dsa-puppet.git] / 3rdparty / modules / openstacklib / manifests / messaging / rabbitmq.pp
1 #
2 # Copyright (C) 2014 eNovance SAS <licensing@enovance.com>
3 #
4 # Author: Emilien Macchi <emilien.macchi@enovance.com>
5 #
6 # Licensed under the Apache License, Version 2.0 (the "License"); you may
7 # not use this file except in compliance with the License. You may obtain
8 # a copy of the License at
9 #
10 #      http://www.apache.org/licenses/LICENSE-2.0
11 #
12 # Unless required by applicable law or agreed to in writing, software
13 # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14 # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15 # License for the specific language governing permissions and limitations
16 # under the License.
17 #
18 # == Definition: openstacklib::messaging::rabbitmq
19 #
20 # This resource creates RabbitMQ resources for an OpenStack service.
21 #
22 # == Parameters:
23 #
24 # [*userid*]
25 #   (optional) The username to use when connecting to Rabbit
26 #   Defaults to 'guest'
27 #
28 # [*password*]
29 #   (optional) The password to use when connecting to Rabbit
30 #   Defaults to 'guest'
31 #
32 # [*virtual_host*]
33 #   (optional) The virtual host to use when connecting to Rabbit
34 #   Defaults to '/'
35 #
36 # [*is_admin*]
37 #   (optional) If the user should be admin or not
38 #   Defaults to false
39 #
40 # [*configure_permission*]
41 #   (optional) Define configure permission
42 #   Defaults to '.*'
43 #
44 # [*write_permission*]
45 #   (optional) Define write permission
46 #   Defaults to '.*'
47 #
48 # [*read_permission*]
49 #   (optional) Define read permission
50 #   Defaults to '.*'
51 #
52 # [*manage_user*]
53 #   (optional) Manage or not the user
54 #   Defaults to true
55 #
56 # [*manage_user_permissions*]
57 #   (optional) Manage or not user permissions
58 #   Defaults to true
59 #
60 # [*manage_vhost*]
61 #   (optional) Manage or not the vhost
62 #   Defaults to true
63 #
64 define openstacklib::messaging::rabbitmq(
65   $userid                  = 'guest',
66   $password                = 'guest',
67   $virtual_host            = '/',
68   $is_admin                = false,
69   $configure_permission    = '.*',
70   $write_permission        = '.*',
71   $read_permission         = '.*',
72   $manage_user             = true,
73   $manage_user_permissions = true,
74   $manage_vhost            = true,
75 ) {
76
77   if $manage_user {
78     if $userid == 'guest' {
79       $is_admin_real = false
80     } else {
81       $is_admin_real = $is_admin
82     }
83     ensure_resource('rabbitmq_user', $userid, {
84       'admin'    => $is_admin_real,
85       'password' => $password,
86       'provider' => 'rabbitmqctl',
87     })
88   }
89
90   if $manage_user_permissions {
91     ensure_resource('rabbitmq_user_permissions', "${userid}@${virtual_host}", {
92       'configure_permission' => $configure_permission,
93       'write_permission'     => $write_permission,
94       'read_permission'      => $read_permission,
95       'provider'             => 'rabbitmqctl',
96     })
97   }
98
99   if $manage_vhost {
100     ensure_resource('rabbitmq_vhost', $virtual_host, {
101       'provider' => 'rabbitmqctl',
102     })
103   }
104
105 }