Skip to content

Commit

Permalink
ansible-scylla-node: Improves "legacy" support for 'node-exporter'
Browse files Browse the repository at this point in the history
This patch improves how 'node_exporter_install' is called and how 'node-exporter' service is started.

Fixes: scylladb#249

Signed-off-by: Eduardo Benzecri <[email protected]>
  • Loading branch information
ebenzecri committed Jun 21, 2023
1 parent b2249bb commit b58dcec
Show file tree
Hide file tree
Showing 5 changed files with 48 additions and 21 deletions.
36 changes: 31 additions & 5 deletions ansible-scylla-node/handlers/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,38 @@
name: scylla-server
state: stopped

- name: node_exporter start
- name: Enable and start 'node-exporter.service' service (legacy)
block:
- name: Disable and stop 'scylla-node-exporter.service' service
ansible.builtin.service:
name: scylla-node-exporter.service
state: stopped
enabled: no
when: ansible_facts.services["scylla-node-exporter.service"] is defined

- name: Enable and start 'node-exporter.service' service (legacy)
ansible.builtin.service:
name: node-exporter.service
state: started
enabled: yes
become: true
service:
name: node-exporter
state: started
enabled: yes
when: ansible_facts.services["node-exporter.service"] is defined

- name: Enable and start 'scylla-node-exporter.service' service
block:
- name: Disable and stop 'node-exporter.service' service (legacy)
ansible.builtin.service:
name: node-exporter.service
state: stopped
enabled: no
when: ansible_facts.services["node-exporter.service"] is defined

- name: Enable and start 'scylla-node-exporter.service' service
ansible.builtin.service:
name: scylla-node-exporter.service
state: started
enabled: yes
when: ansible_facts.services["scylla-node-exporter.service"] is defined

- name: Enable and start 'scylla-fstrim.timer' service
ansible.builtin.service:
Expand Down
1 change: 1 addition & 0 deletions ansible-scylla-node/tasks/Debian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
- name: Install Scylla packages
include_tasks: Debian_install.yml
become: true
notify: Enable and start 'scylla-node-exporter.service' service

# TODO: Implement this for the debian based distros
# - name: install prerequisite python-yaml
Expand Down
1 change: 1 addition & 0 deletions ansible-scylla-node/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@
lock_timeout: 60
when: scylla_version != 'latest' and scylla_edition == 'enterprise'
become: true
notify: Enable and start 'scylla-node-exporter.service' service

- name: Configure SELinux
shell: |
Expand Down
25 changes: 11 additions & 14 deletions ansible-scylla-node/tasks/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -114,23 +114,20 @@
become: true
when: skip_ntp is defined and skip_ntp|bool == false

- name: node exporter setup
shell: |
- name: Check if 'node_exporter_install' exists (legacy)
ansible.builtin.stat:
path: /usr/sbin/node_exporter_install
register: node_exporter_install

- name: Run 'node_exporter_install' (legacy)
ansible.builtin.shell: |
node_exporter_install --force
when: install_type == 'online'
become: true
notify:
- node_exporter start
ignore_errors: true
#TODO: stop ignoring errors when the node_exporter_install script fix is available in all actual versions, resp. use only for < 5.0 / 2022

- name: node exporter setup from 5.0/2022
service:
name: scylla-node-exporter
state: started
become: true
ignore_errors: true
#TODO: stop ignoring errors when a version check is added
- Enable and start 'node-exporter.service' service (legacy)
when:
- install_type == 'online'
- node_exporter_install.stat.exists

- name: configure Scylla
shell: |
Expand Down
6 changes: 4 additions & 2 deletions ansible-scylla-node/tasks/upgrade/post_upgrade.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
ansible.builtin.service:
name: scylla-server
state: started
notify: scylla-manager-agent restart
notify:
- scylla-manager-agent restart
- Enable and start 'node-exporter.service' service (legacy)
- Enable and start 'scylla-node-exporter.service' service
become: true

0 comments on commit b58dcec

Please sign in to comment.