Defined Type: rabbitmq::user

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

Overview

Parameters:

  • password (String[1])
  • username (String[1]) (defaults to: $title)
  • ensure (Wmflib::Ensure) (defaults to: 'present')
  • permissions (String[1]) (defaults to: '".*" ".*" ".*"')
  • administrator (Boolean) (defaults to: false)


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'],
        }
    }
}