This repository has been archived by the owner on Jan 30, 2024. It is now read-only.
/
rabbitmq.pp
85 lines (80 loc) · 2.91 KB
/
rabbitmq.pp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
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
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
# == Class: govuk::apps::email_alert_service::rabbitmq
#
# Permissions for the email_alert_service to read messages from
# the publishing API's AMQP exchange.
#
# This sets up the user, and permits read/write/configure
# to the queue, and read-only to the exchange.
#
# === Parameters
#
# [*ensure*]
# Ensure the RabbitMQ state is setup, or not.
#
# [*amqp_user*]
# The RabbitMQ username (default: 'email_alert_service')
#
# [*amqp_pass*]
# The RabbitMQ password (default: 'email_alert_service')
#
# [*amqp_exchange*]
# The RabbitMQ exchange to read from (default: 'published_documents')
#
# [*amqp_queue*]
# The RabbitMQ queue to set up for workers of this type to read from
# (default: 'email_alert_service')
#
# [*queue_size_critical_threshold*]
# The number of unprocessed messages which can build up before triggering
# a critical alert.
#
# [*queue_size_warning_threshold*]
# The number of unprocessed messages which can build up before triggering
# a warning.
#
class govuk::apps::email_alert_service::rabbitmq (
$ensure = 'present',
$amqp_user = 'email_alert_service',
$amqp_pass = 'email_alert_service',
$amqp_exchange = 'published_documents',
$amqp_major_change_queue = 'email_alert_service',
$amqp_unpublishing_queue = 'email_unpublishing',
$queue_size_critical_threshold,
$queue_size_warning_threshold,
) {
govuk_rabbitmq::queue_with_binding { $amqp_major_change_queue:
ensure => $ensure,
amqp_exchange => $amqp_exchange,
amqp_queue => $amqp_major_change_queue,
routing_key => '*.major.#',
durable => true,
} ->
govuk_rabbitmq::monitor_messages {"${amqp_major_change_queue}_message_monitoring":
ensure => $ensure,
rabbitmq_hostname => 'localhost',
rabbitmq_queue => $amqp_major_change_queue,
critical_threshold => $queue_size_critical_threshold,
warning_threshold => $queue_size_warning_threshold,
} ->
govuk_rabbitmq::queue_with_binding { $amqp_unpublishing_queue:
ensure => $ensure,
amqp_exchange => $amqp_exchange,
amqp_queue => $amqp_unpublishing_queue,
routing_key => 'redirect.unpublish.#',
durable => true,
} ->
govuk_rabbitmq::monitor_messages {"${amqp_unpublishing_queue}_message_monitoring":
ensure => $ensure,
rabbitmq_hostname => 'localhost',
rabbitmq_queue => $amqp_unpublishing_queue,
critical_threshold => $queue_size_critical_threshold,
warning_threshold => $queue_size_warning_threshold,
} ->
govuk_rabbitmq::consumer { $amqp_user:
ensure => $ensure,
amqp_pass => $amqp_pass,
read_permission => "^(amq\\.gen.*|${amqp_major_change_queue}|${amqp_unpublishing_queue}|${amqp_exchange})\$",
write_permission => "^(amq\\.gen.*|${amqp_major_change_queue}|${amqp_unpublishing_queue})\$",
configure_permission => "^(amq\\.gen.*|${amqp_major_change_queue}|${amqp_unpublishing_queue})\$",
}
}