18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
|
# File 'modules/rabbitmq/manifests/user.pp', line 18
define rabbitmq::user(
String[1] $password,
String[1] $username = $title,
Wmflib::Ensure $ensure = 'present',
String[1] $permissions = '".*" ".*" ".*"',
Boolean $administrator = false,
) {
if $ensure == 'present' {
exec { "rabbit_${username}_create":
command => "/usr/sbin/rabbitmqctl add_user ${username} ${password}",
unless => "/usr/sbin/rabbitmqctl list_users | grep --quiet ${username}",
require => Service['rabbitmq-server'],
notify => Exec["rabbit_${username}_setup_perms"],
}
exec { "rabbit_${username}_setup_perms":
command => "/usr/sbin/rabbitmqctl set_permissions ${username} ${permissions}",
refreshonly => true,
require => Service['rabbitmq-server'],
}
if $administrator {
exec { "rabbit_user_${username}_adminstrator_tag":
command => "/usr/sbin/rabbitmqctl set_user_tags ${username} administrator",
subscribe => Exec["rabbit_${username}_setup_perms"],
require => Service['rabbitmq-server'],
refreshonly => true,
}
}
} else {
exec { "${username}-rabbit_user_removal":
command => "/usr/sbin/rabbitmqctl delete_user ${username}",
onlyif => "/usr/sbin/rabbitmqctl list_users | grep --quiet ${username}",
require => Service['rabbitmq-server'],
}
}
}
|