Skip to content

Commit c708636

Browse files
committed
add role for cruise control deployment
1 parent 9dc967b commit c708636

File tree

8 files changed

+613
-0
lines changed

8 files changed

+613
-0
lines changed
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Cruise Control Role
2+
3+
Perform installation and configuration of Cruise Control.
4+
5+
| Variable | Description | Default |
6+
|:---------|:------------|:--------|
7+
|`amq_streams_cruise_control_home`| Path to folder where Cruise Control has been installed | `/opt/cruise-control/` |
8+
|`amq_streams_cruise_control_service_name`| Name of the systemd service running Cruise Control | `amq_streams_cruise_control` |
9+
|`amq_streams_cruise_control_server_start`| Path to start script for systemd service managing Cruise Control | `{{ amq_streams_cruise_control_home }}/kafka-cruise-control-start.sh` |
10+
|`amq_streams_cruise_control_server_stop`| Path to stop script for systemd service managing Cruise Control | `{{ amq_streams_cruise_control_home }}/kafka-cruise-control-stop.sh` |
11+
|`amq_streams_cruise_control_server_config`| Path to config file for Cruise Control service | `/etc/amq_streams_cruise_control.properties` |
12+
|`amq_streams_cruise_control_config_template`| Path to template defining the systemd service for Cruise Control | `templates/service.conf.j2` |
13+
|`amq_streams_cruise_control_config_properties_template`| Path to template defining the config file for Cruise Control | `templates/cruisecontrol.properties.j2` |
14+
|`amq_streams_cruise_control_user`| User account running the Cruise Control service | `root` |
15+
|`amq_streams_cruise_control_group`| Groupname of the account running the Cruise Control service | `root` |
16+
|`amq_streams_cruise_control_zk_host`| Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble | `{{ groups['zookeepers'][0] }}` |
17+
|`amq_streams_cruise_control_broker_host`| Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble | `{{ groups['brokers'][0] }}` |
18+
|`amq_streams_cruise_control_host`| Name of the host system running Cruise Control | `localhost` |
19+
|`amq_streams_cruise_control_port`| Port used communicate with Cruise Control | `9090` |
20+
|`amq_streams_cruise_control_api_path`| Context of the HTTP API call to Cruise Control (don't modify unless you know what you are doing) | `kafkacruisecontrol` |
21+
|`amq_streams_cruise_control_operation_exec`| Set to False to display the URL built, but do not execute it (debug) | `True` |
22+
23+
## License
24+
25+
Apache License v2.0 or later
26+
27+
## Author Information
28+
29+
* [Romain Pelisse](https://github.com/rpelisse)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
---
2+
amq_streams_cruise_control_home: /opt/cruise-control/
3+
amq_streams_cruise_control_service_name: amq_streams_cruise_control
4+
amq_streams_cruise_control_server_start: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-start.sh"
5+
amq_streams_cruise_control_server_stop: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-stop.sh"
6+
amq_streams_cruise_control_server_config: "/etc/amq_streams_cruise_control.properties"
7+
amq_streams_cruise_control_config_template: 'templates/service.conf.j2'
8+
amq_streams_cruise_control_config_properties_template: 'templates/cruisecontrol.properties.j2'
9+
amq_streams_cruise_control_user: root
10+
amq_streams_cruise_control_group: root
11+
amq_streams_cruise_control_zk_host: "{{ groups['zookeepers'][0] }}"
12+
amq_streams_cruise_control_broker_host: "{{ groups['brokers'][0] }}"
13+
# Cruise Control HTTP API
14+
amq_streams_cruise_control_host: 'localhost'
15+
amq_streams_cruise_control_port: 9090
16+
amq_streams_cruise_control_api_path: 'kafkacruisecontrol'
17+
# Switch next var to False to display the HTTP request
18+
amq_streams_cruise_control_operation_exec: True
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
---
2+
- name: "Restart {{ amq_streams_cruise_control_service_name }}"
3+
ansible.builtin.service:
4+
name: "{{ amq_streams_cruise_control_service_name }}"
5+
state: restarted
6+
become: yes
7+
8+
- name: "Stop {{ amq_streams_cruise_control_service_name }}"
9+
ansible.builtin.service:
10+
name: "{{ amq_streams_cruise_control_service_name }}"
11+
state: stopped
12+
become: yes
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
argument_specs:
2+
main:
3+
options:
4+
# line 2 of defaults/main.yml
5+
amq_streams_cruise_control_home:
6+
default: "/opt/cruise-control/"
7+
description: "Path to folder where Cruise Control has been installed"
8+
type: "str"
9+
10+
# line 3 of defaults/main.yml
11+
amq_streams_cruise_control_service_name:
12+
default: "amq_streams_cruise_control"
13+
description: "Name of the systemd service running Cruise Control"
14+
type: "str"
15+
16+
# line 4 of defaults/main.yml
17+
amq_streams_cruise_control_server_start:
18+
default: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-start.sh"
19+
description: "Path to start script for systemd service managing Cruise Control"
20+
type: "str"
21+
22+
# line 5 of defaults/main.yml
23+
amq_streams_cruise_control_server_stop:
24+
default: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-stop.sh"
25+
description: "Path to stop script for systemd service managing Cruise Control"
26+
type: "str"
27+
28+
# line 6 of defaults/main.yml
29+
amq_streams_cruise_control_server_config:
30+
default: "/etc/amq_streams_cruise_control.properties"
31+
description: "Path to config file for Cruise Control service"
32+
type: "str"
33+
34+
# line 7 of defaults/main.yml
35+
amq_streams_cruise_control_config_template:
36+
default: "templates/service.conf.j2"
37+
description: "Path to template defining the systemd service for Cruise Control"
38+
type: "str"
39+
40+
# line 8 of defaults/main.yml
41+
amq_streams_cruise_control_config_properties_template:
42+
default: "templates/cruisecontrol.properties.j2"
43+
description: "Path to template defining the config file for Cruise Control"
44+
type: "str"
45+
46+
# line 9 of defaults/main.yml
47+
amq_streams_cruise_control_user:
48+
default: "root"
49+
description: "User account running the Cruise Control service"
50+
type: "str"
51+
52+
# line 10 of defaults/main.yml
53+
amq_streams_cruise_control_group:
54+
default: "root"
55+
description: "Groupname of the account running the Cruise Control service"
56+
type: "str"
57+
58+
# line 11 of defaults/main.yml
59+
amq_streams_cruise_control_zk_host:
60+
default: "{{ groups['zookeepers'][0] }}"
61+
description: "Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble"
62+
type: "str"
63+
64+
# line 12 of defaults/main.yml
65+
amq_streams_cruise_control_broker_host:
66+
default: "{{ groups['brokers'][0] }}"
67+
description: "Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble"
68+
type: "str"
69+
70+
# line 14 of defaults/main.yml
71+
amq_streams_cruise_control_host:
72+
default: "localhost"
73+
description: "Name of the host system running Cruise Control"
74+
type: "str"
75+
76+
# line 15 of defaults/main.yml
77+
amq_streams_cruise_control_port:
78+
default: 9090
79+
description: "Port used communicate with Cruise Control"
80+
type: "int"
81+
82+
# line 16 of defaults/main.yml
83+
amq_streams_cruise_control_api_path:
84+
default: "kafkacruisecontrol"
85+
description: "Context of the HTTP API call to Cruise Control (don't modify unless you know what you are doing)"
86+
type: "str"
87+
amq_streams_cruise_control_operation_exec:
88+
default: True
89+
description: "Indicate if the request must be executed or just diplayed (for debugging purpose)"
90+
type: "bool"
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
---
2+
collections:
3+
- middleware_automation.common
4+
5+
galaxy_info:
6+
role_name: amq_streams_cruise_control
7+
namespace: middleware_automation
8+
author: Romain Pelisse
9+
description: Install AMQ Streams Zookeeper server
10+
company: Red Hat, Inc.
11+
12+
license: Apache License 2.0
13+
14+
min_ansible_version: "2.12"
15+
16+
platforms:
17+
- name: EL
18+
versions:
19+
- 8
20+
21+
galaxy_tags:
22+
- java
23+
- jboss
24+
- wildfly
25+
- cli
26+
- server
27+
28+
dependencies:
29+
- { role: amq_streams_common }
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
---
2+
- name: "Ensure required parameters have been provided"
3+
ansible.builtin.assert:
4+
that:
5+
- amq_streams_cruise_control_host is defined and amq_streams_cruise_control_host | length > 0
6+
- amq_streams_cruise_control_port is defined and amq_streams_cruise_control_port | string | length > 0
7+
- operation_name is defined and operation_name | length > 0
8+
quiet: true
9+
10+
- name: "Build request"
11+
ansible.builtin.set_fact:
12+
cruise_control_url_request: "http://{{ amq_streams_cruise_control_host }}:{{ amq_streams_cruise_control_port }}/{{ amq_streams_cruise_control_api_path }}/{{ operation_name }}"
13+
14+
- name: "Use Cruise Control to perform {{ operation_name }} on the cluster"
15+
when:
16+
- amq_streams_cruise_control_operation_exec is defined and amq_streams_cruise_control_operation_exec
17+
block:
18+
- name: "Execute request"
19+
ansible.builtin.uri:
20+
url: "{{ cruise_control_url_request }}"
21+
method: POST
22+
return_content: True
23+
register: operation_result
24+
25+
rescue:
26+
- name: "Display Cruise Control response to operation request ({{ operation_name }})"
27+
ansible.builtin.debug:
28+
var: operation_result
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
- name: "Ensure required parameter(s) are defined."
3+
ansible.builtin.assert:
4+
that:
5+
- amq_stream_cruise_control_home is defined
6+
quiet: true
7+
8+
- name: "Ensure Cruise Control artifacts are available."
9+
ansible.builtin.include_role:
10+
name: amq_streams_common
11+
12+
- name: "Ensure Cruise Control artifacts are available."
13+
ansible.builtin.include_role:
14+
name: amq_streams_common
15+
tasks_from: install.yml
16+
17+
# TODO deal with FW, if enabled
18+
19+
- name: "Deploy Cruise Control as a systemd service."
20+
ansible.builtin.include_role:
21+
name: amq_streams_common
22+
tasks_from: systemd.yml
23+
vars:
24+
# service_systemd_workdir: "{{ amq_streams_common_home }}"
25+
server_name: "{{ amq_streams_cruise_control_service_name }}"
26+
server_start: "{{ amq_streams_cruise_control_server_start }}"
27+
server_stop: "{{ amq_streams_cruise_control_server_stop }}"
28+
server_config: "{{ amq_streams_cruise_control_server_config }}"
29+
server_config_template: "{{ amq_streams_cruise_control_config_properties_template }}"
30+
# service_systemd_env_file: "{{ amq_streams_connect_systemd_env_file }}"
31+
# service_systemd_env_file_template: "{{ amq_streams_connect_service_config_template }}"
32+
# server_log_dir: "{{ amq_streams_connect_logs_dir | default(omit) }}"
33+
# server_extra_args: "{{ amq_streams_connect_server_extra_args }}"
34+
server_user: "{{ amq_streams_cruise_control_user }}"
35+
server_group: "{{ amq_streams_cruise_control_group }}"
36+
# server_java_opts: "{{ amq_streams_connect_java_opts | default('') }}"
37+
# server_log4j_opts: "{{ amq_streams_connect_java_log4j_opts | default('') }}"
38+
# server_java_heap_opts: "{{ amq_streams_connect_java_heap_opts | default('') }}"
39+
# server_java_performance_opts: "{{ amq_streams_connect_java_performance_opts | default('') }}"
40+
# server_java_gc_log_opts: "{{ amq_streams_connect_java_java_gc_log_opts | default('') }}"
41+
# server_start_sleep: "{{ amq_streams_connect_zookeeper_session_timeout_ms }}"

0 commit comments

Comments
 (0)