forked from confluentinc/cp-ansible
-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade_kafka_connect.yml
85 lines (74 loc) · 3.14 KB
/
upgrade_kafka_connect.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
---
- name: Kafka Connect Upgrade
hosts: kafka_connect
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
- shell: "egrep -i 'ssl.client.auth ?= ?true' {{ kafka_connect.config_file }}"
register: mtls_check
failed_when: false
- name: Set MTLS Variable
set_fact:
kafka_connect_ssl_mutual_auth_enabled: "{{ true if mtls_check.rc == 0 else false}}"
- name: Get Package Facts
package_facts:
manager: auto
when: installation_method == "package"
- name: Set kafka_connect_current_version variable - Package
set_fact:
confluent_server_enabled: "{{ True if ansible_facts.packages['confluent-server'] is defined else False }}"
kafka_connect_current_version: "{{ ansible_facts.packages['confluent-kafka-connect-replicator'][0]['version'] }}"
when: installation_method == "package"
- name: Load override.conf
slurp:
src: "{{ kafka_connect.systemd_override }}"
register: slurped_override
when: installation_method == "archive"
- name: Set kafka_connect_current_version variable - Archive
set_fact:
kafka_connect_current_version: "{{ (slurped_override.content|b64decode) .split('\n') |
select('match', '^ExecStart=' + archive_config_base_path + '/confluent-(.*)/bin/connect-distributed ' + kafka_connect.config_file) |
list | first | regex_search('[0-9]+(.[0-9]+)+') }}"
when: installation_method == "archive"
- debug:
msg: "Current version: {{kafka_connect_current_version}} Upgrade to version: {{confluent_package_version}}"
- name: Upgrade Kafka Connect - Package
include_tasks: tasks/upgrade_component.yml
vars:
service_name: "{{ kafka_connect_service_name }}"
packages: "{{ kafka_connect_packages }}"
backup_files:
- "{{ kafka_connect.config_file }}"
- "{{ kafka_connect.systemd_override }}"
restore_files:
- "{{ kafka_connect.config_file }}"
when:
- kafka_connect_current_version != confluent_full_package_version
- kafka_connect_current_version != confluent_package_version
- installation_method == "package"
- name: Upgrade Kafka Connect - Archive
include_tasks: tasks/upgrade_component_archive.yml
vars:
service_name: "{{ kafka_connect_service_name }}"
systemd_file: "{{ kafka_connect.systemd_file }}"
systemd_override: "{{ kafka_connect.systemd_override }}"
start_script: "connect-distributed"
config_file: "{{ kafka_connect.config_file }}"
when:
- kafka_connect_current_version != confluent_full_package_version
- kafka_connect_current_version != confluent_package_version
- installation_method == "archive"
- name: Kafka Connect Health Check
import_role:
name: confluent.kafka_connect
tasks_from: health_check.yml
when: not ansible_check_mode