Skip to content

Commit

Permalink
tweak rhn download to work with cruise control
Browse files Browse the repository at this point in the history
  • Loading branch information
rpelisse committed Dec 8, 2023
1 parent 6546e1d commit 2427f7e
Show file tree
Hide file tree
Showing 10 changed files with 53 additions and 6 deletions.
2 changes: 1 addition & 1 deletion galaxy.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
namespace: middleware_automation
name: amq_streams
version: "0.0.7"
version: "0.0.8"
readme: README.md
authors:
- Romain Pelisse <[email protected]>
Expand Down
1 change: 1 addition & 0 deletions roles/amq_streams_common/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ amq_streams_common_rhn_product_category: 'jboss.amq.streams'
amq_streams_common_scala_version: 2.13
amq_streams_common_version: "{{ amq_streams_common_scala_version }}-{{ amq_streams_common_product_version }}"
amq_streams_common_archive_file: "kafka_{{ amq_streams_common_version }}.tgz"
amq_streams_common_rhn_product_archive_file_pattern: '^.*/amq-streams-[0-9.]*-bin.zip$'
amq_streams_common_download_url: "https://archive.apache.org/dist/kafka/{{ amq_streams_common_product_version }}/kafka_{{ amq_streams_common_version }}.tgz"
amq_streams_common_download_dir: /tmp
amq_streams_common_download_user: "{{ amq_streams_common_user | default(omit) }}"
Expand Down
5 changes: 4 additions & 1 deletion roles/amq_streams_common/tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@

- name: "Download archive from RHN"
ansible.builtin.include_tasks: rhn/main.yml
vars:
rhn_product_archive_file_pattern: "{{ amq_streams_common_rhn_product_archive_file_pattern }}"
when:
- amq_streams_common_redhat_enabled is defined and amq_streams_common_redhat_enabled
- not amq_streams_common_offline_install is defined or not amq_streams_common_offline_install
Expand All @@ -37,12 +39,13 @@
path: "{{ amq_streams_common_home }}/{{ amq_streams_common_subdir | default('bin') }}"
register: download_target

- name: "Extract artifact to {{ amq_streams_common_install_dir }}"
- name: "Extract artifact {{ amq_streams_common_archive_file }} to {{ amq_streams_common_install_dir }}"
ansible.builtin.unarchive:
src: "{{ amq_streams_common_download_dir }}/{{ amq_streams_common_archive_file }}"
dest: "{{ amq_streams_common_install_dir }}"
owner: "{{ amq_streams_common_user | default(omit) }}"
group: "{{ amq_streams_common_group | default(omit) }}"
remote_src: "{{ amq_streams_common_download_remote_src | default('no') }}"
creates: "{{ amq_streams_common_archive_creates_control_file | default(omit) }}"
when:
- download_target is defined and download_target.stat is defined and not download_target.stat.exists
2 changes: 1 addition & 1 deletion roles/amq_streams_common/tasks/rhn/download.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
quiet: True
fail_msg: "Path for download product is not writeable on the Ansible controller: {{ rhn_product_path }}."

- name: "Download Red Hat product into {{ rhn_product_path }} (rhn_download_become: {{ rhn_download_become }})"
- name: "Download Red Hat product #{{ rhn_product_id }} into {{ rhn_product_path }}"
middleware_automation.common.product_download: # noqa risky-file-permissions delegated, uses controller host user
client_id: "{{ rhn_username }}"
client_secret: "{{ rhn_password }}"
Expand Down
8 changes: 7 additions & 1 deletion roles/amq_streams_common/tasks/rhn/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,15 @@
rhn_product_category: "{{ amq_streams_common_rhn_product_category }}"
rhn_product_version: "{{ amq_streams_common_rhn_product_version }}" #"{{ amq_version.split('.')[:2] | join('.') }}"

- name: "Set archive file pattern - if not defined."
ansible.builtin.set_fact:
rhn_product_archive_file_pattern: '^.*/amq-streams-[0-9.]*-bin.zip$'
when:
- not rhn_product_archive_file_pattern is defined or rhn_product_archive_file_pattern == ""

- name: "Determine which archive to download"
ansible.builtin.set_fact:
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', '^.*/amq-streams-[0-9.]*-bin.zip$') }}"
rhn_filtered_products: "{{ rhn_products.results | selectattr('file_path', 'match', rhn_product_archive_file_pattern) }}"

- name: "Download rhn_filtered_products[0]"
ansible.builtin.include_role:
Expand Down
3 changes: 3 additions & 0 deletions roles/amq_streams_cruise_control/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
---
amq_streams_cruise_control_home: /opt/cruise-control/
rhn_product_archive_file_pattern: '^.*/amq-streams-[0-9.]*-cruise-control-bin.zip'
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_common_archive_file: amq-streams-2.5.1-cruise-control-bin.zip
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'
Expand All @@ -15,6 +17,7 @@ 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] }}"
amq_streams_cruise_control_replicator_factor: 1
# Cruise Control HTTP API
amq_streams_cruise_control_host: 'localhost'
amq_streams_cruise_control_port: 9090
Expand Down
17 changes: 17 additions & 0 deletions roles/amq_streams_cruise_control/tasks/jaas_config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
- name: "Ensure required credentials have been provided."
ansible.builtin.assert:
that:
- amq_streams_broker_inventory_group is defined and amq_streams_broker_inventory_group | length > 0
- amq_streams_broker_username is defined and amq_streams_broker_username | length > 0
- amq_streams_broker_password is defined and amq_streams_broker_password | length > 0
quiet: true

- name: "Generate required JAAS config based on provided credentials."
ansible.builtin.set_fact:
amq_streams_cruise_control_zk_sasl_jaas_config: "org.apache.kafka.common.security.plain.PlainLoginModule required username=\"{{ amq_streams_broker_username }}\" password=\"{{ amq_streams_broker_password }}\";"

- name: "Ensure sasl.properties is up to date on broker."
ansible.builtin.template:
src: templates/sasl.properties.j2
dest: "{{ amq_stream_common_home }}/config/sasl.properties"
16 changes: 15 additions & 1 deletion roles/amq_streams_cruise_control/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,20 @@
- name: "Ensure Cruise Control artifacts are available."
ansible.builtin.include_role:
name: amq_streams_common
tasks_from: main.yml

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

- name: "Ensure Cruise Control artifacts are available."
ansible.builtin.include_role:
name: amq_streams_common
tasks_from: install.yml
vars:
amq_streams_common_archive_file: amq-streams-2.5.1-cruise-control-bin.zip
amq_streams_common_archive_creates_control_file: /opt/cruise-control//config

- name: "Deploy custom log4j config (if provided)"
when:
Expand All @@ -36,6 +45,11 @@
when:
- amq_streams_broker_inventory_group is defined and amq_streams_broker_inventory_group | length > 0

- name: "Ensure JAAS config is deployed and up to date (if enabled)"
ansible.builtin.include_tasks: jaas_config.yml
when:
- amq_streams_broker_inter_broker_auth_sasl_protocol is defined and amq_streams_broker_inter_broker_auth_sasl_mechanisms is defined and amq_streams_cruise_control_zk_sasl_jaas_config is defined

#TODO: Deal with FW if enabled

- name: "Deploy Cruise Control as a systemd service."
Expand All @@ -55,7 +69,7 @@
# 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_java_opts: "{{ amq_streams_cruise_control_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('') }}"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ partition.metric.sample.store.topic=__KafkaCruiseControlPartitionMetricSamples
broker.metric.sample.store.topic=__KafkaCruiseControlModelTrainingSamples

# The replication factor of Kafka metric sample store topic
sample.store.topic.replication.factor=2
sample.store.topic.replication.factor={{ amq_streams_cruise_control_replicator_factor }}

# The config for the number of Kafka sample store consumer threads
num.sample.loading.threads=8
Expand Down
3 changes: 3 additions & 0 deletions roles/amq_streams_cruise_control/templates/sasl.properties.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
security.protocol={{ amq_streams_broker_inter_broker_auth_sasl_protocol }}
sasl.mechanism={{ amq_streams_broker_inter_broker_auth_sasl_mechanisms }}
sasl.jaas.config={{ amq_streams_cruise_control_zk_sasl_jaas_config }}

0 comments on commit 2427f7e

Please sign in to comment.