forked from confluentinc/cp-ansible
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade_schema_registry.yml
102 lines (90 loc) · 3.67 KB
/
upgrade_schema_registry.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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
---
- name: Schema Registry Role Bindings
hosts: schema_registry
gather_facts: false
environment: "{{ proxy_env }}"
tasks:
- name: Schema Registry Role Bindings
import_role:
name: confluent.schema_registry
tasks_from: rbac.yml
vars:
cluster_id_source: zookeeper
copy_certs: false
run_once: true
when: rbac_enabled|bool
- name: Schema Registry Upgrade
hosts: schema_registry
gather_facts: false
environment: "{{ proxy_env }}"
serial: 1
# there is a schema registry leader, should think about the master/follower thing
# look in schema reg docs
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' {{ schema_registry.config_file }}"
register: mtls_check
failed_when: false
- name: Set MTLS Variable
set_fact:
schema_registry_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 schema_registry_current_version variable - Package
set_fact:
confluent_server_enabled: "{{ True if ansible_facts.packages['confluent-server'] is defined else False }}"
schema_registry_current_version: "{{ ansible_facts.packages['confluent-schema-registry'][0]['version'] }}"
when: installation_method == "package"
- name: Load override.conf
slurp:
src: "{{ schema_registry.systemd_override }}"
register: slurped_override
when: installation_method == "archive"
- name: Set schema_registry_current_version variable - Archive
set_fact:
schema_registry_current_version: "{{ (slurped_override.content|b64decode) .split('\n') |
select('match', '^ExecStart=' + archive_config_base_path + '/confluent-(.*)/bin/schema-registry-start ' + schema_registry.config_file) |
list | first | regex_search('[0-9]+(.[0-9]+)+') }}"
when: installation_method == "archive"
- debug:
msg: "Current version: {{schema_registry_current_version}} Upgrade to version: {{confluent_package_version}}"
- name: Upgrade Schema Registry - Package
include_tasks: tasks/upgrade_component.yml
vars:
service_name: "{{ schema_registry_service_name }}"
packages: "{{ schema_registry_packages }}"
backup_files:
- "{{ schema_registry.config_file }}"
- "{{ schema_registry.systemd_override }}"
restore_files:
- "{{ schema_registry.config_file }}"
when:
- schema_registry_current_version != confluent_full_package_version
- schema_registry_current_version != confluent_package_version
- installation_method == "package"
- name: Upgrade Schema Registry - Archive
include_tasks: tasks/upgrade_component_archive.yml
vars:
service_name: "{{ schema_registry_service_name }}"
systemd_file: "{{ schema_registry.systemd_file }}"
systemd_override: "{{ schema_registry.systemd_override }}"
start_script: "schema-registry-start"
config_file: "{{ schema_registry.config_file }}"
when:
- schema_registry_current_version != confluent_full_package_version
- schema_registry_current_version != confluent_package_version
- installation_method == "archive"
- name: Schema Registry Health Check
import_role:
name: confluent.schema_registry
tasks_from: health_check.yml
when: not ansible_check_mode