Defined Type: rabbitmq::user

Defined in:
modules/rabbitmq/manifests/user.pp

Overview

Parameters:

  • username (Any)
  • password (Any)
  • ensure (Any) (defaults to: 'present')
  • permissions (Any) (defaults to: '".*" ".*" ".*"')
  • administrator (Any) (defaults to: false)


17
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
# File 'modules/rabbitmq/manifests/user.pp', line 17

define rabbitmq::user(
    $username,
    $password,
    $ensure='present',
    $permissions='".*" ".*" ".*"',
    $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}",
            notify  => Exec["rabbit_${username}_setup_perms"],
        }

        exec {"rabbit_${username}_setup_perms":
            command     => "/usr/sbin/rabbitmqctl set_permissions ${username} ${permissions}",
            refreshonly => true,
        }

        if ($administrator) {
            exec {"rabbit_user_${username}_adminstrator_tag":
                command     => "/usr/sbin/rabbitmqctl set_user_tags ${username} administrator",
                subscribe   => Exec["rabbit_${username}_setup_perms"],
                refreshonly => true,
            }
        }
    }

    if ($ensure == 'absent') {
        exec {"${username}-rabbit_user_removal":
            command => "/usr/sbin/rabbitmqctl delete_user ${username}",
            onlyif  => "/usr/sbin/rabbitmqctl list_users | grep --quiet ${username}",
        }
    }
}