Puppet Class: st2::profile::rabbitmq

Inherits:
st2
Defined in:
manifests/profile/rabbitmq.pp

Summary

StackStorm compatable installation of RabbitMQ and dependencies.

Overview

Examples:

Basic Usage

include st2::profile::rabbitmq

Authentication enabled (configured vi st2)

class { 'st2':
  rabbitmq_username => 'rabbitst2',
  rabbitmq_password => 'secret123',
}
include st2::profile::rabbitmq

Parameters:

  • username (Any) (defaults to: $st2::rabbitmq_username)

    User to create within RabbitMQ for authentication.

  • password (Any) (defaults to: $st2::rabbitmq_password)

    Password of username for RabbitMQ authentication.

  • port (Any) (defaults to: $st2::rabbitmq_port)

    Port to bind to for the RabbitMQ server

  • bind_ip (Any) (defaults to: $st2::rabbitmq_bind_ip)

    IP address to bind to for the RabbitMQ server

  • vhost (Any) (defaults to: $st2::rabbitmq_vhost)

    RabbitMQ virtual host to create for StackStorm

  • erlang_url (Any) (defaults to: $st2::erlang_url)
  • erlang_key (Any) (defaults to: $st2::erlang_key)
  • erlang_key_id (Any) (defaults to: $st2::erlang_key_id)
  • erlang_key_source (Any) (defaults to: $st2::erlang_key_source)
  • erlang_packages (Any) (defaults to: $st2::erlang_packages)
  • erlang_rhel_sslcacert_location (Any) (defaults to: $st2::erlang_rhel_sslcacert_location)
  • erlang_rhel_sslverify (Any) (defaults to: $st2::erlang_rhel_sslverify)
  • erlang_rhel_gpgcheck (Any) (defaults to: $st2::erlang_rhel_gpgcheck)
  • erlang_rhel_repo_gpgcheck (Any) (defaults to: $st2::erlang_rhel_repo_gpgcheck)


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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
# File 'manifests/profile/rabbitmq.pp', line 24

class st2::profile::rabbitmq (
  $username                       = $st2::rabbitmq_username,
  $password                       = $st2::rabbitmq_password,
  $port                           = $st2::rabbitmq_port,
  $bind_ip                        = $st2::rabbitmq_bind_ip,
  $vhost                          = $st2::rabbitmq_vhost,
  $erlang_url                     = $st2::erlang_url,
  $erlang_key                     = $st2::erlang_key,
  $erlang_key_id                  = $st2::erlang_key_id,
  $erlang_key_source              = $st2::erlang_key_source,
  $erlang_packages                = $st2::erlang_packages,
  $erlang_rhel_sslcacert_location = $st2::erlang_rhel_sslcacert_location,
  $erlang_rhel_sslverify          = $st2::erlang_rhel_sslverify,
  $erlang_rhel_gpgcheck           = $st2::erlang_rhel_gpgcheck,
  $erlang_rhel_repo_gpgcheck      = $st2::erlang_rhel_repo_gpgcheck,
) inherits st2 {

  # RHEL 8 Requires another repo in addition to epel to be installed
  if ($facts['os']['family'] == 'RedHat') {
    $repos_ensure = true

    # This is required because when using the latest version of rabbitmq because the latest version in EPEL
    # for Erlang is 22.0.7 which is not compatible: https://www.rabbitmq.com/which-erlang.html
    yumrepo { 'erlang':
      ensure        => present,
      name          => 'rabbitmq_erlang',
      baseurl       => $erlang_url,
      gpgkey        => $erlang_key,
      enabled       => 1,
      gpgcheck      => $erlang_rhel_gpgcheck,
      repo_gpgcheck => $erlang_rhel_repo_gpgcheck,
      before        => Class['rabbitmq::repo::rhel'],
      sslverify     => $erlang_rhel_sslverify,
      sslcacert     => $erlang_rhel_sslcacert_location,
    }
  }
  elsif ($facts['os']['family'] == 'Debian') {
    $repos_ensure = true
    # trusty, xenial, bionic, etc
    $release = downcase($facts['os']['distro']['codename'])
    $repos = 'main'

    apt::source { 'erlang':
      ensure   => 'present',
      location => $erlang_url,
      release  => $release,
      repos    => $repos,
      pin      => '1000',
      key      => {
        'id'     => $erlang_key_id,
        'source' => $erlang_key_source,
      },
      notify   => Exec['apt-get-clean'],
      tag      => ['st2::rabbitmq::sources'],
    }
    # rebuild apt cache since we just changed repositories
    # Executing it manually here to avoid dep cycles
    exec { 'apt-get-clean':
      command     => '/usr/bin/apt-get -y clean',
      refreshonly => true,
      notify      => Exec['apt-get-update'],
    }
    exec { 'apt-get-update':
      command     => '/usr/bin/apt-get -y update',
      refreshonly => true,
    }
    package { $erlang_packages:
      ensure  => 'present',
      tag     => ['st2::packages', 'st2::rabbitmq::packages'],
      require => Exec['apt-get-update'],
    }
  }
  else {
    $repos_ensure = false
  }

  # In new versions of the RabbitMQ module we need to explicitly turn off
  # the ranch TCP settings so that Kombu can connect via AMQP
  class { 'rabbitmq' :
    config_ranch          => false,
    repos_ensure          => $repos_ensure,
    delete_guest_user     => true,
    port                  => $port,
    environment_variables => {
      'RABBITMQ_NODE_IP_ADDRESS' => $st2::rabbitmq_bind_ip,
    },
    manage_python         => false,
  }
  contain 'rabbitmq'

  rabbitmq_user { $username:
    admin    => true,
    password => $password,
  }

  rabbitmq_vhost { $vhost:
    ensure => present,
  }

  rabbitmq_user_permissions { "${username}@${vhost}":
    configure_permission => '.*',
    read_permission      => '.*',
    write_permission     => '.*',
  }

  # RHEL needs EPEL installed prior to rabbitmq
  if $facts['os']['family'] == 'RedHat' {
    Class['epel']
    -> Class['rabbitmq']

    Yumrepo['epel']
    -> Class['rabbitmq']

    Yumrepo['epel']
    -> Package['rabbitmq-server']
  }
  # Debian/Ubuntu needs erlang before rabbitmq
  elsif $facts['os']['family'] == 'Debian' {
    Package<| tag == 'st2::rabbitmq::packages' |>
    -> Class['rabbitmq']
  }
}