-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into feature/upgr-node-eporter-2747
- Loading branch information
Showing
29 changed files
with
445 additions
and
305 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
|
||
- hosts: all | ||
gather_facts: yes | ||
tasks: [ ] | ||
tasks: [ ] | ||
|
||
- hosts: kafka | ||
become: true | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
jmx_exporter_bin_filename: "jmx_prometheus_javaagent-0.16.1.jar" | ||
jmx_exporter_version: 0.16.1 | ||
jmx_exporter_directory: /opt/jmx-exporter | ||
prometheus_jmx_exporter_path: /opt/jmx-exporter/jmx_prometheus_javaagent.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
101 changes: 101 additions & 0 deletions
101
ansible/playbooks/roles/jmx_exporter/tasks/upgrade/main.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
--- | ||
|
||
- name: Check for upgrade flag file | ||
stat: | ||
path: "{{ lock_file }}" | ||
register: lock_file_status | ||
|
||
- name: Preflight check | ||
when: not lock_file_status.stat.exists | ||
block: | ||
- name: Check for binary | ||
stat: | ||
path: "{{ prometheus_jmx_exporter_path }}" | ||
register: jmx_exporter_binary | ||
|
||
- name: Inform and fail if JMX exporter binary is missing | ||
when: not jmx_exporter_binary.stat.exists | ||
fail: | ||
msg: > | ||
There is no JMX exporter binary at all, | ||
re-apply your configuration or remove jmx_exporter role from inventory | ||
- name: Verify installed version | ||
when: jmx_exporter_binary.stat.exists | ||
block: | ||
- name: Get installed jmx-exporter version | ||
shell: >- | ||
unzip -p /opt/jmx-exporter/jmx_prometheus_javaagent.jar META-INF/MANIFEST.MF \ | ||
| awk '$1 == "Implementation-Version:" {print $2}' | ||
register: installed_jmx_exporter_version | ||
|
||
- name: Set version facts | ||
set_fact: | ||
jmx_exporter_version: | ||
old: "{{ installed_jmx_exporter_version.stdout }}" | ||
new: "{{ jmx_exporter_version }}" | ||
|
||
- name: Avoiding risk of downgrade | ||
when: jmx_exporter_version.old is not version( jmx_exporter_version.new, '<' ) | ||
debug: | ||
msg: "Skipping upgrade: JMX Exporter in newer version already installed!" | ||
|
||
- name: Upgrade | jmx-exporter | ||
when: > | ||
jmx_exporter_version.old is version( jmx_exporter_version.new, '<' ) or | ||
lock_file_status.stat.exists | ||
block: | ||
- name: Create upgrade flag file | ||
file: | ||
path: "{{ lock_file }}" | ||
state: touch | ||
|
||
- name: Download jmx-exporter binaries | ||
include_role: | ||
name: download | ||
tasks_from: download_file | ||
vars: | ||
file_name: "{{ jmx_exporter_bin_filename }}" | ||
|
||
- name: Copy jmx-exporter binaries to jmx-exporter directory | ||
copy: | ||
src: "{{ download_directory }}/{{ jmx_exporter_bin_filename }}" | ||
dest: "{{ jmx_exporter_directory }}/{{ jmx_exporter_bin_filename }}" | ||
owner: "{{ specification.jmx_exporter_user }}" | ||
group: "{{ specification.jmx_exporter_group }}" | ||
remote_src: yes | ||
|
||
- name: Get installed jmx-exporter binary path | ||
stat: | ||
path: "{{ prometheus_jmx_exporter_path }}" | ||
get_attributes: false | ||
get_checksum: false | ||
get_mime: false | ||
register: linked_jmx | ||
|
||
- name: Reconfigure {{ prometheus_jmx_exporter_path }} symlink to point to the new version | ||
file: | ||
dest: "{{ prometheus_jmx_exporter_path }}" | ||
state: link | ||
src: "{{ jmx_exporter_directory }}/{{ jmx_exporter_bin_filename }}" | ||
force: yes | ||
|
||
- name: Run systemctl daemon-reload # zookeeper and kafka configure jmx-exporter via systemd units | ||
systemd: | ||
state: restarted | ||
daemon_reload: true | ||
name: "{{ item }}" | ||
with_items: | ||
- zookeeper | ||
- kafka | ||
|
||
- name: Remove previous binary version | ||
file: | ||
path: "{{ linked_jmx.stat.lnk_target }}" | ||
state: absent | ||
|
||
- name: Remove upgrade flag file | ||
file: | ||
path: "{{ lock_file }}" | ||
state: absent | ||
... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
kafka_version: 2.6.0 | ||
scala_version: 2.12 | ||
kafka_bin_filename: "kafka_2.12-2.6.0.tgz" | ||
prometheus_jmx_exporter_path: /opt/jmx-exporter/jmx_prometheus_javaagent.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.