Skip to content

Commit

Permalink
Merge pull request confluentinc#107 from confluentinc/61x-release-tes…
Browse files Browse the repository at this point in the history
…ting-upgrade

Tar upgrade changes
  • Loading branch information
domenicbove committed Feb 8, 2021
2 parents d2e0bd9 + 6838ff3 commit 95ce1b2
Show file tree
Hide file tree
Showing 10 changed files with 409 additions and 118 deletions.
4 changes: 3 additions & 1 deletion roles/confluent.variables/defaults/main.yml
Expand Up @@ -100,6 +100,8 @@ confluent_archive_scala_version: 2.12
### The path the downloaded archive is expanded into. Using the default with a `confluent_package_version` of *5.5.1* results in the following installation path `/opt/confluent/confluent-5.5.1/` that contains directories such as `bin` and `share`, but may be overridden usinf the `binary_base_path` property.
archive_destination_path: "/opt/confluent"

archive_version: "{{confluent_package_version}}"

### Owner of the downloaded archive. Not mandatory to set.
archive_owner: ""

Expand Down Expand Up @@ -265,7 +267,7 @@ zookeeper_health_check_command: "{% if zookeeper_sasl_protocol in ['kerberos', '
-Dzookeeper.ssl.keyStore.password={{zookeeper_keystore_storepass}}
-Dzookeeper.client.secure=true
{% endif %}
org.apache.zookeeper.client.FourLetterWordMain {{inventory_hostname}} {{zookeeper_client_port}} srvr
org.apache.zookeeper.client.FourLetterWordMain {{zookeeper_health_check_host | default(inventory_hostname)}} {{zookeeper_client_port}} srvr
{% if zookeeper_ssl_enabled|bool %}true{% endif %}"

zookeeper_current_node_hostname: "{{ inventory_hostname }}"
Expand Down
3 changes: 2 additions & 1 deletion roles/confluent.variables/vars/main.yml
Expand Up @@ -1115,7 +1115,8 @@ control_center_combined_properties: "{{control_center_properties | combine_prope
control_center_final_properties: "{{ control_center_combined_properties | combine(control_center_custom_properties) }}"

### The base path for the binary files. When in Archive File deployment mode this results in binary files being based in, for example `/opt/confluent/confluent-5.5.1/bin`, otherwise they are based in `/usr/bin`.
binary_base_path: "{{ archive_config_base_path+'/confluent-'+confluent_package_version if installation_method == 'archive' else '/usr' }}"
binary_base_path: "{{ archive_config_base_path+'/confluent-'+archive_version if installation_method == 'archive' else '/usr' }}"


#### Kafka Connect Replicator Variables ####
kafka_connect_replicator_service_name: confluent-kafka-connect-replicator
Expand Down
31 changes: 31 additions & 0 deletions tasks/upgrade_component_archive.yml
@@ -0,0 +1,31 @@
---
- name: Stop Service
systemd:
name: "{{ service_name }}"
state: stopped

- name: Configure Repositories
import_role:
name: confluent.common
vars:
install_java: false

- name: Copy Service from Archive Directory to System
copy:
src: "{{binary_base_path}}/lib/systemd/system/{{systemd_file|basename}}"
remote_src: true
dest: "{{systemd_file}}"
mode: 0644
force: true

- name: Update Override to Use New Version
lineinfile:
path: "{{ systemd_override }}"
line: "ExecStart={{archive_config_base_path}}/confluent-{{confluent_package_version}}/bin/{{start_script}} {{config_file}}"
regexp: "ExecStart={{archive_config_base_path}}/confluent-(.*)/bin/{{start_script}} {{config_file}}"

- name: Restart Service
systemd:
daemon_reload: true
name: "{{ service_name }}"
state: restarted
48 changes: 39 additions & 9 deletions upgrade_control_center.yml
@@ -1,32 +1,48 @@
---
- name: Control Center Upgrade
hosts: control_center
gather_facts: false
environment: "{{ proxy_env }}"
serial: 1
tasks:
- name: Gather OS Facts
setup:
# Only gathers items in list, filters out the rest
filter: ansible_os_family
gather_subset:
- '!all'

- import_role:
name: confluent.variables

- name: Get Package Facts
package_facts:
manager: auto
when: installation_method == "package"

- set_fact:
confluent_server_enabled: true
when: ansible_facts.packages['confluent-server'] is defined
- name: Set control_center_current_version variable - Package
set_fact:
confluent_server_enabled: "{{ True if ansible_facts.packages['confluent-server'] is defined else False }}"
control_center_current_version: "{{ ansible_facts.packages['confluent-control-center'][0]['version'] }}"
when: installation_method == "package"

- set_fact:
confluent_server_enabled: false
when: ansible_facts.packages['confluent-kafka-2.12'] is defined
- name: Load override.conf
slurp:
src: "{{ control_center.systemd_override }}"
register: slurped_override
when: installation_method == "archive"

- name: Set Current Package Version
- name: Set control_center_current_version variable - Archive
set_fact:
control_center_current_version: "{{ ansible_facts.packages['confluent-control-center'][0]['version'] }}"
control_center_current_version: "{{ (slurped_override.content|b64decode) .split('\n') |
select('match', '^ExecStart=' + archive_config_base_path + '/confluent-(.*)/bin/control-center-start ' + control_center.config_file) |
list | first | regex_search('[0-9]+(.[0-9]+)+') }}"
when: installation_method == "archive"

- debug:
msg: "Current version: {{control_center_current_version}} Upgrade to version: {{confluent_package_version}}"

- name: Upgrade Control Center
- name: Upgrade Control Center - Package
include_tasks: tasks/upgrade_component.yml
vars:
service_name: "{{ control_center_service_name }}"
Expand All @@ -39,6 +55,20 @@
when:
- control_center_current_version != confluent_full_package_version
- control_center_current_version != confluent_package_version
- installation_method == "package"

- name: Upgrade Control Center - Archive
include_tasks: tasks/upgrade_component_archive.yml
vars:
service_name: "{{ control_center_service_name }}"
systemd_file: "{{ control_center.systemd_file }}"
systemd_override: "{{ control_center.systemd_override }}"
start_script: "control-center-start"
config_file: "{{ control_center.config_file }}"
when:
- control_center_current_version != confluent_full_package_version
- control_center_current_version != confluent_package_version
- installation_method == "archive"

- name: Control Center Health Check
import_role:
Expand Down

0 comments on commit 95ce1b2

Please sign in to comment.