Skip to content

Commit e220514

Browse files
committed
Import artemis create configuration tasks
1 parent 91964a9 commit e220514

File tree

6 files changed

+329
-16
lines changed

6 files changed

+329
-16
lines changed

roles/amq_broker/defaults/main.yml

+37-4
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,44 @@ amq_broker_port_stomp: 61613 # for protocols [STOMP]
4343

4444
### Enable configuration for high availability
4545
amq_broker_ha_enabled: False
46+
amq_broker_cluster_user: amq-cluster-user
47+
amq_broker_cluster_pass: amq-cluster-pass
48+
amq_broker_cluster_maxhops: 1
49+
amq_broker_cluster_lb_policy: ON_DEMAND
50+
amq_broker_replicate: False
51+
amq_broker_replicated: False
4652

4753
### Enable database configuration for JDBC persistence
4854
amq_broker_db_enabled: False
4955

50-
### Enable SSLServerSocket transport
51-
amq_broker_ssl_enabled: False
52-
amq_broker_ssl_keystore_path: broker.ks
53-
amq_broker_ssl_keystore_password: changeme
56+
### Enable TLS
57+
amq_broker_tls_enabled: False
58+
amq_broker_tls_keystore_path: identity.ks
59+
amq_broker_tls_keystore_password: changeme
60+
amq_broker_tls_keystore_dest: "{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/identity.ks"
61+
62+
# Mutual authentication (requires TLS)
63+
amq_broker_tls_mutual_authentication: False
64+
amq_broker_tls_truststore:
65+
amq_broker_tls_truststore_password:
66+
amq_broker_tls_truststore_dest: "{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/trust.ks"
67+
68+
# NIO option
69+
amq_broker_nio_enabled: False
70+
71+
## Shared Storage
72+
amq_broker_shared_storage: False
73+
74+
## Ports
75+
amq_broker_ports_offset_enabled: False
76+
amq_broker_ports_offset: 0
77+
78+
# Queues
79+
amq_broker_disable_destination_autocreate: True
80+
amq_broker_queues: queue.in,queue.out
81+
82+
# Protocol disablement
83+
amq_broker_disable_amqp_protocol: False
84+
amq_broker_disable_hornetq_protocol: False
85+
amq_broker_disable_mqtt_protocol: False
86+
amq_broker_disable_stomp_protocol: False

roles/amq_broker/meta/argument_specs.yml

+115-10
Original file line numberDiff line numberDiff line change
@@ -177,25 +177,130 @@ argument_specs:
177177
description: "Whether to enable clustering"
178178
type: "bool"
179179
amq_broker_db_enabled:
180-
# line 48 of defaults/main.yml
180+
# line 54 of defaults/main.yml
181181
default: false
182182
description: "Whether to enable JDBC persistence"
183183
type: "bool"
184-
amq_broker_ssl_enabled:
184+
amq_broker_cluster_user:
185+
# line 46 of defaults/main.yml
186+
default: "amq-cluster-user"
187+
description: "Cluster username"
188+
type: "str"
189+
amq_broker_cluster_pass:
190+
# line 47 of defaults/main.yml
191+
default: "amq-cluster-pass"
192+
description: "Cluster user password"
193+
type: "str"
194+
amq_broker_cluster_maxhops:
195+
# line 48 of defaults/main.yml
196+
default: 1
197+
description: "Cluster max hops"
198+
type: "int"
199+
amq_broker_cluster_lb_policy:
200+
# line 49 of defaults/main.yml
201+
default: "ON_DEMAND"
202+
description: "Policy for cluster load balancing"
203+
type: "str"
204+
amq_broker_replicate:
205+
# line 50 of defaults/main.yml
206+
default: false
207+
description: "Enables replication"
208+
type: "bool"
209+
amq_broker_replicated:
185210
# line 51 of defaults/main.yml
186211
default: false
187-
description: "Whether to enable SSL listeners"
212+
description: "Designate instance as replicated node"
188213
type: "bool"
189-
amq_broker_ssl_keystore_path:
190-
# line 52 of defaults/main.yml
191-
default: "broker.ks"
192-
description: "Keystore path for SSL listener"
214+
amq_broker_tls_enabled:
215+
# line 57 of defaults/main.yml
216+
default: false
217+
description: "Whether to enable TLS"
218+
type: "bool"
219+
amq_broker_tls_keystore_path:
220+
# line 58 of defaults/main.yml
221+
default: "identity.ks"
222+
description: "Keystore path for TLS connections"
193223
type: "str"
194-
amq_broker_ssl_keystore_password:
195-
# line 53 of defaults/main.yml
224+
amq_broker_tls_keystore_password:
225+
# line 59 of defaults/main.yml
196226
default: "changeme"
197-
description: "Keystore password for SSL listener"
227+
description: "Keystore password for TLS connections"
228+
type: "str"
229+
amq_broker_tls_keystore_dest:
230+
# line 60 of defaults/main.yml
231+
default: "{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/identity.ks"
232+
description: "Path for installation of truststore"
233+
type: "str"
234+
amq_broker_tls_mutual_authentication:
235+
# line 63 of defaults/main.yml
236+
default: false
237+
description: "Whether to enable TLS mutual auth, requires TLS enabled"
238+
type: "bool"
239+
amq_broker_tls_truststore:
240+
# line 64 of defaults/main.yml
241+
default: None
242+
description: "Truststore to use for TLS mutual authentication"
243+
type: "str"
244+
amq_broker_tls_truststore_password:
245+
# line 65 of defaults/main.yml
246+
default: None
247+
description: "Password for truststore"
198248
type: "str"
249+
amq_broker_tls_truststore_dest:
250+
# line 66 of defaults/main.yml
251+
default: "{{ amq_broker_dest }}/{{ amq_broker_instance_name }}/etc/trust.ks"
252+
description: "Path for installation of truststore"
253+
type: "str"
254+
amq_broker_nio_enabled:
255+
# line 69 of defaults/main.yml
256+
default: false
257+
description: "Enable Native IO using libaio"
258+
type: "bool"
259+
amq_broker_shared_storage:
260+
# line 72 of defaults/main.yml
261+
default: false
262+
description: "Use shared filesystem directory for storage"
263+
type: "bool"
264+
amq_broker_ports_offset_enabled:
265+
# line 75 of defaults/main.yml
266+
default: false
267+
description: "Whether to enable port offset"
268+
type: "bool"
269+
amq_broker_ports_offset:
270+
# line 76 of defaults/main.yml
271+
default: 0
272+
description: "Port offset for all default ports"
273+
type: "int"
274+
amq_broker_disable_destination_autocreate:
275+
# line 79 of defaults/main.yml
276+
default: true
277+
description: "Disable automatic creation of destination"
278+
type: "bool"
279+
amq_broker_queues:
280+
# line 80 of defaults/main.yml
281+
default: "queue.in,queue.out"
282+
description: "Queue names comma separated"
283+
type: "str"
284+
amq_broker_disable_amqp_protocol:
285+
# line 83 of defaults/main.yml
286+
default: false
287+
description: "Whether to disable AMQP protocol"
288+
type: "bool"
289+
amq_broker_disable_hornetq_protocol:
290+
# line 84 of defaults/main.yml
291+
default: false
292+
description: "Whether to disable HORNETQ protocol"
293+
type: "bool"
294+
amq_broker_disable_mqtt_protocol:
295+
# line 85 of defaults/main.yml
296+
default: false
297+
description: "Whether to disable MQTT protocol"
298+
type: "bool"
299+
amq_broker_disable_stomp_protocol:
300+
# line 86 of defaults/main.yml
301+
default: false
302+
description: "Whether to disable STOMP protocol"
303+
type: "bool"
199304
amq_broker_rhn_baseurl:
200305
# line 8 of vars/main.yml
201306
default: "https://access.redhat.com/jbossnetwork/restricted/softwareDownload.html?softwareId="

roles/amq_broker/tasks/configure.yml

+156
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
---
2+
- name: Create broker cluster node members
3+
set_fact:
4+
amq_broker_cluster_nodes: >
5+
{{ amq_broker_cluster_nodes | default( [] ) + [
6+
{
7+
"name": amq_broker.instance_name,
8+
"address": item,
9+
"inventory_host": item,
10+
"value": "tcp://" + item + ":" + (((61616|int + amq_broker_ports_offset|int)|abs)|string)
11+
}
12+
] }}
13+
loop: "{{ ansible_play_batch }}"
14+
15+
- name: Prepare broker creation options
16+
set_fact:
17+
amq_broker_options:
18+
- "--name {{ amq_broker.instance_name }}"
19+
20+
- name: Enable clustering
21+
set_fact:
22+
amq_broker_options:
23+
- "{{ amq_broker_options | join(' ') }}"
24+
- "--clustered"
25+
- "--cluster-user {{ amq_broker_cluster_user }}"
26+
- "--cluster-password {{ amq_broker_cluster_pass }}"
27+
- "--max-hops {{ amq_broker_cluster_maxhops }}"
28+
- "--message-load-balancing {{ amq_broker_cluster_load_balancing_policy }}"
29+
- "--failover-on-shutdown"
30+
when: amq_broker_ha_enabled
31+
32+
- name: Enable security
33+
set_fact:
34+
amq_broker_options:
35+
- "{{ amq_broker_options | join(' ') }}"
36+
- "--require-login"
37+
- "--user {{ amq_broker_instance_username }}"
38+
- "--password {{ amq_broker_instance_password }}"
39+
when: not amq_broker_instance_anonymous
40+
41+
- name: Set address broker accepts connections on
42+
set_fact:
43+
amq_broker_options:
44+
- "{{ amq_broker_options | join(' ') }}"
45+
- "--host {{ amq_broker_host }}"
46+
47+
- name: Set address embedded web server accepts connections on
48+
set_fact:
49+
amq_broker_options:
50+
- "{{ amq_broker_options | join(' ') }}"
51+
- "--http-host {{ amq_broker_host }}"
52+
53+
- name: Disable automatic creation of queues
54+
set_fact:
55+
amq_broker_options:
56+
- "{{ amq_broker_options | join(' ') }}"
57+
- "--no-autocreate"
58+
when: amq_broker_disable_destination_autocreate
59+
60+
- name: Set up queues
61+
set_fact:
62+
amq_broker_options:
63+
- "{{ amq_broker_options | join(' ') }}"
64+
- "--queues {{ amq_broker_queues }}"
65+
66+
- name: Set up data directory
67+
set_fact:
68+
amq_broker_options:
69+
- "{{ amq_broker_options | join(' ') }}"
70+
- "--data {{ amq_broker.instance_home }}/data"
71+
when: not amq_broker_shared_storage
72+
73+
- name: Set as replicated node
74+
set_fact:
75+
amq_broker_options:
76+
- "{{ amq_broker_options | join(' ') }}"
77+
- "--slave"
78+
when: amq_broker_replicate
79+
80+
- name: Enable replication
81+
set_fact:
82+
amq_broker_options:
83+
- "{{ amq_broker_options | join(' ') }}"
84+
- "--replicated"
85+
when: amq_broker_replicated
86+
87+
- name: Enable shared storage
88+
set_fact:
89+
amq_broker_options:
90+
- "{{ amq_broker_options | join(' ') }}"
91+
- "--shared-store"
92+
- "--data {{ amq_broker.home }}/data"
93+
when: amq_broker_shared_storage
94+
95+
- name: Set up port offset
96+
set_fact:
97+
amq_broker_options:
98+
- "{{ amq_broker_options | join(' ') }}"
99+
- "--port-offset {{ (0|int + amq_broker_ports_offset|int)|abs }}"
100+
when: amq_broker_ports_offset_enabled
101+
102+
- name: Disable AMQP protocol
103+
set_fact:
104+
amq_broker_options:
105+
- "{{ amq_broker_options | join(' ') }}"
106+
- "--no-amqp-acceptor"
107+
when: amq_broker_disable_amqp_protocol
108+
109+
- name: Disable HornetQ protocol
110+
set_fact:
111+
amq_broker_options:
112+
- "{{ amq_broker_options | join(' ') }}"
113+
- "--no-hornetq-acceptor"
114+
when: amq_broker_disable_hornetq_protocol
115+
116+
- name: Disable MQTT protocol
117+
set_fact:
118+
amq_broker_options:
119+
- "{{ amq_broker_options | join(' ') }}"
120+
- "--no-mqtt-acceptor"
121+
when: amq_broker_disable_mqtt_protocol
122+
123+
- name: Disable STOMP
124+
set_fact:
125+
amq_broker_options:
126+
- "{{ amq_broker_options | join(' ') }}"
127+
- "--no-stomp-acceptor"
128+
when: amq_broker_disable_stomp_protocol
129+
130+
- name: Set the journal as nio
131+
set_fact:
132+
amq_broker_options:
133+
- "{{ amq_broker_options | join(' ') }}"
134+
- "--nio"
135+
when: amq_broker_nio_enabled
136+
137+
- name: Enable TLS for web UI
138+
set_fact:
139+
amq_broker_options:
140+
- "{{ amq_broker_options | join(' ') }}"
141+
- "--ssl-key {{ amq_broker_tls_keystore_dest }}"
142+
- "--ssl-key-password {{ amq_broker_tls_keystore_password }}"
143+
when: amq_broker_tls_enabled and amq_broker_tls_keystore and amq_broker_tls_keystore_password
144+
145+
- name: Enable TLS client authentication for web UI
146+
set_fact:
147+
amq_broker_options:
148+
- "{{ amq_broker_options | join(' ') }}"
149+
- "--ssl-trust {{ amq_broker_tls_truststore_dest }}"
150+
- "--ssl-trust-password {{ amq_broker_tls_truststore_password }}"
151+
- "--use-client-auth"
152+
when: amq_broker_tls_enabled and amq_broker_tls_mutual_authentication and amq_broker_tls_truststore and amq_broker_tls_truststore_password
153+
154+
- name: Create final broker creation options
155+
set_fact:
156+
amq_broker_options: "{{ amq_broker_options | join(' ') }}"

roles/amq_broker/tasks/prereqs.yml

+10-1
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,20 @@
2424
fail_msg: "Cannot install Red Hat AMQ Broker without RHN credentials. Check rhn_username and rhn_password are defined"
2525
success_msg: "{{ 'Installing Red Hat AMQ Broker' if amq_broker_enable else 'Installing Apache ActiveMQ' }}"
2626

27+
- name: Validate TLS mutual auth config
28+
ansible.builtin.assert:
29+
that:
30+
- amq_broker_tls_truststore is defined
31+
- amq_broker_tls_truststore_password is defined
32+
- amq_broker_tls_enabled
33+
when: amq_broker_tls_mutual_authentication
34+
2735
- name: Ensure required packages are installed
2836
ansible.builtin.include_tasks: fastpackages.yml
2937
vars:
3038
packages_list:
3139
- "{{ amq_broker_jvm_package }}"
3240
- unzip
3341
- procps-ng
34-
- initscripts
42+
- initscripts
43+
- libaio

roles/amq_broker/tasks/systemd.yml

+7-1
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,17 @@
3939
register: instance_directory
4040
become: yes
4141

42+
- name: "Generate configuration for: {{ amq_broker_dest }}/{{ amq_broker.instance_name }}"
43+
ansible.builtin.include_tasks: configure.yml
44+
when:
45+
- not instance_directory.stat.exists
46+
4247
- name: "Create instance {{ amq_broker.instance_name }} of {{ amq_broker.service_name }}"
4348
ansible.builtin.command:
44-
cmd: "{{ amq_broker.home }}/bin/artemis create {{ amq_broker_dest }}/{{ amq_broker.instance_name }} --user {{ amq_broker_instance_username }} --password {{ amq_broker_instance_password }} --require-login"
49+
cmd: "{{ amq_broker.home }}/bin/artemis create {{ amq_broker.instance_home }} {{ amq_broker_options }}"
4550
creates: "{{ amq_broker.instance_home }}/bin/artemis-service"
4651
become: yes
52+
register: broker_created
4753
when:
4854
- not instance_directory.stat.exists
4955

0 commit comments

Comments
 (0)