Skip to content

Commit

Permalink
add role for cruise control deployment
Browse files Browse the repository at this point in the history
  • Loading branch information
rpelisse committed Sep 28, 2023
1 parent 9dc967b commit c708636
Show file tree
Hide file tree
Showing 8 changed files with 613 additions and 0 deletions.
29 changes: 29 additions & 0 deletions roles/amq_streams_cruise_control/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Cruise Control Role

Perform installation and configuration of Cruise Control.

| Variable | Description | Default |
|:---------|:------------|:--------|
|`amq_streams_cruise_control_home`| Path to folder where Cruise Control has been installed | `/opt/cruise-control/` |
|`amq_streams_cruise_control_service_name`| Name of the systemd service running Cruise Control | `amq_streams_cruise_control` |
|`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` |
|`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` |
|`amq_streams_cruise_control_server_config`| Path to config file for Cruise Control service | `/etc/amq_streams_cruise_control.properties` |
|`amq_streams_cruise_control_config_template`| Path to template defining the systemd service for Cruise Control | `templates/service.conf.j2` |
|`amq_streams_cruise_control_config_properties_template`| Path to template defining the config file for Cruise Control | `templates/cruisecontrol.properties.j2` |
|`amq_streams_cruise_control_user`| User account running the Cruise Control service | `root` |
|`amq_streams_cruise_control_group`| Groupname of the account running the Cruise Control service | `root` |
|`amq_streams_cruise_control_zk_host`| Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble | `{{ groups['zookeepers'][0] }}` |
|`amq_streams_cruise_control_broker_host`| Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble | `{{ groups['brokers'][0] }}` |
|`amq_streams_cruise_control_host`| Name of the host system running Cruise Control | `localhost` |
|`amq_streams_cruise_control_port`| Port used communicate with Cruise Control | `9090` |
|`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` |
|`amq_streams_cruise_control_operation_exec`| Set to False to display the URL built, but do not execute it (debug) | `True` |

## License

Apache License v2.0 or later

## Author Information

* [Romain Pelisse](https://github.com/rpelisse)
18 changes: 18 additions & 0 deletions roles/amq_streams_cruise_control/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
amq_streams_cruise_control_home: /opt/cruise-control/
amq_streams_cruise_control_service_name: amq_streams_cruise_control
amq_streams_cruise_control_server_start: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-start.sh"
amq_streams_cruise_control_server_stop: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-stop.sh"
amq_streams_cruise_control_server_config: "/etc/amq_streams_cruise_control.properties"
amq_streams_cruise_control_config_template: 'templates/service.conf.j2'
amq_streams_cruise_control_config_properties_template: 'templates/cruisecontrol.properties.j2'
amq_streams_cruise_control_user: root
amq_streams_cruise_control_group: root
amq_streams_cruise_control_zk_host: "{{ groups['zookeepers'][0] }}"
amq_streams_cruise_control_broker_host: "{{ groups['brokers'][0] }}"
# Cruise Control HTTP API
amq_streams_cruise_control_host: 'localhost'
amq_streams_cruise_control_port: 9090
amq_streams_cruise_control_api_path: 'kafkacruisecontrol'
# Switch next var to False to display the HTTP request
amq_streams_cruise_control_operation_exec: True
12 changes: 12 additions & 0 deletions roles/amq_streams_cruise_control/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
- name: "Restart {{ amq_streams_cruise_control_service_name }}"
ansible.builtin.service:
name: "{{ amq_streams_cruise_control_service_name }}"
state: restarted
become: yes

- name: "Stop {{ amq_streams_cruise_control_service_name }}"
ansible.builtin.service:
name: "{{ amq_streams_cruise_control_service_name }}"
state: stopped
become: yes
90 changes: 90 additions & 0 deletions roles/amq_streams_cruise_control/meta/argument_specs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
argument_specs:
main:
options:
# line 2 of defaults/main.yml
amq_streams_cruise_control_home:
default: "/opt/cruise-control/"
description: "Path to folder where Cruise Control has been installed"
type: "str"

# line 3 of defaults/main.yml
amq_streams_cruise_control_service_name:
default: "amq_streams_cruise_control"
description: "Name of the systemd service running Cruise Control"
type: "str"

# line 4 of defaults/main.yml
amq_streams_cruise_control_server_start:
default: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-start.sh"
description: "Path to start script for systemd service managing Cruise Control"
type: "str"

# line 5 of defaults/main.yml
amq_streams_cruise_control_server_stop:
default: "{{ amq_streams_cruise_control_home }}/kafka-cruise-control-stop.sh"
description: "Path to stop script for systemd service managing Cruise Control"
type: "str"

# line 6 of defaults/main.yml
amq_streams_cruise_control_server_config:
default: "/etc/amq_streams_cruise_control.properties"
description: "Path to config file for Cruise Control service"
type: "str"

# line 7 of defaults/main.yml
amq_streams_cruise_control_config_template:
default: "templates/service.conf.j2"
description: "Path to template defining the systemd service for Cruise Control"
type: "str"

# line 8 of defaults/main.yml
amq_streams_cruise_control_config_properties_template:
default: "templates/cruisecontrol.properties.j2"
description: "Path to template defining the config file for Cruise Control"
type: "str"

# line 9 of defaults/main.yml
amq_streams_cruise_control_user:
default: "root"
description: "User account running the Cruise Control service"
type: "str"

# line 10 of defaults/main.yml
amq_streams_cruise_control_group:
default: "root"
description: "Groupname of the account running the Cruise Control service"
type: "str"

# line 11 of defaults/main.yml
amq_streams_cruise_control_zk_host:
default: "{{ groups['zookeepers'][0] }}"
description: "Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble"
type: "str"

# line 12 of defaults/main.yml
amq_streams_cruise_control_broker_host:
default: "{{ groups['brokers'][0] }}"
description: "Hostname of the Zookeeper instance used by Cruise Control to communicate with the ensemble"
type: "str"

# line 14 of defaults/main.yml
amq_streams_cruise_control_host:
default: "localhost"
description: "Name of the host system running Cruise Control"
type: "str"

# line 15 of defaults/main.yml
amq_streams_cruise_control_port:
default: 9090
description: "Port used communicate with Cruise Control"
type: "int"

# line 16 of defaults/main.yml
amq_streams_cruise_control_api_path:
default: "kafkacruisecontrol"
description: "Context of the HTTP API call to Cruise Control (don't modify unless you know what you are doing)"
type: "str"
amq_streams_cruise_control_operation_exec:
default: True
description: "Indicate if the request must be executed or just diplayed (for debugging purpose)"
type: "bool"
29 changes: 29 additions & 0 deletions roles/amq_streams_cruise_control/meta/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
collections:
- middleware_automation.common

galaxy_info:
role_name: amq_streams_cruise_control
namespace: middleware_automation
author: Romain Pelisse
description: Install AMQ Streams Zookeeper server
company: Red Hat, Inc.

license: Apache License 2.0

min_ansible_version: "2.12"

platforms:
- name: EL
versions:
- 8

galaxy_tags:
- java
- jboss
- wildfly
- cli
- server

dependencies:
- { role: amq_streams_common }
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
---
- name: "Ensure required parameters have been provided"
ansible.builtin.assert:
that:
- amq_streams_cruise_control_host is defined and amq_streams_cruise_control_host | length > 0
- amq_streams_cruise_control_port is defined and amq_streams_cruise_control_port | string | length > 0
- operation_name is defined and operation_name | length > 0
quiet: true

- name: "Build request"
ansible.builtin.set_fact:
cruise_control_url_request: "http://{{ amq_streams_cruise_control_host }}:{{ amq_streams_cruise_control_port }}/{{ amq_streams_cruise_control_api_path }}/{{ operation_name }}"

- name: "Use Cruise Control to perform {{ operation_name }} on the cluster"
when:
- amq_streams_cruise_control_operation_exec is defined and amq_streams_cruise_control_operation_exec
block:
- name: "Execute request"
ansible.builtin.uri:
url: "{{ cruise_control_url_request }}"
method: POST
return_content: True
register: operation_result

rescue:
- name: "Display Cruise Control response to operation request ({{ operation_name }})"
ansible.builtin.debug:
var: operation_result
41 changes: 41 additions & 0 deletions roles/amq_streams_cruise_control/tasks/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
---
- name: "Ensure required parameter(s) are defined."
ansible.builtin.assert:
that:
- amq_stream_cruise_control_home is defined
quiet: true

- name: "Ensure Cruise Control artifacts are available."
ansible.builtin.include_role:
name: amq_streams_common

- name: "Ensure Cruise Control artifacts are available."
ansible.builtin.include_role:
name: amq_streams_common
tasks_from: install.yml

# TODO deal with FW, if enabled

- name: "Deploy Cruise Control as a systemd service."
ansible.builtin.include_role:
name: amq_streams_common
tasks_from: systemd.yml
vars:
# service_systemd_workdir: "{{ amq_streams_common_home }}"
server_name: "{{ amq_streams_cruise_control_service_name }}"
server_start: "{{ amq_streams_cruise_control_server_start }}"
server_stop: "{{ amq_streams_cruise_control_server_stop }}"
server_config: "{{ amq_streams_cruise_control_server_config }}"
server_config_template: "{{ amq_streams_cruise_control_config_properties_template }}"
# service_systemd_env_file: "{{ amq_streams_connect_systemd_env_file }}"
# service_systemd_env_file_template: "{{ amq_streams_connect_service_config_template }}"
# server_log_dir: "{{ amq_streams_connect_logs_dir | default(omit) }}"
# server_extra_args: "{{ amq_streams_connect_server_extra_args }}"
server_user: "{{ amq_streams_cruise_control_user }}"
server_group: "{{ amq_streams_cruise_control_group }}"
# server_java_opts: "{{ amq_streams_connect_java_opts | default('') }}"
# server_log4j_opts: "{{ amq_streams_connect_java_log4j_opts | default('') }}"
# server_java_heap_opts: "{{ amq_streams_connect_java_heap_opts | default('') }}"
# server_java_performance_opts: "{{ amq_streams_connect_java_performance_opts | default('') }}"
# server_java_gc_log_opts: "{{ amq_streams_connect_java_java_gc_log_opts | default('') }}"
# server_start_sleep: "{{ amq_streams_connect_zookeeper_session_timeout_ms }}"
Loading

0 comments on commit c708636

Please sign in to comment.