Skip to content

Commit

Permalink
scylla-monitoring: auto-detect Scylla Manager version
Browse files Browse the repository at this point in the history
If -M option is not set in scylla_monitoring_params try auto-detecting SM version
using 'sctool version' on the Manager VM in there is a non-empty
'scylla-manager' inventory section.

Signed-off-by: Vlad Zolotarov <[email protected]>
  • Loading branch information
vladzcloudius committed Mar 13, 2024
1 parent bcfc31f commit 0d0ae27
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 5 deletions.
4 changes: 3 additions & 1 deletion ansible-scylla-monitoring/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ rule_config_yml_path: rule_config.yml
# Example: "1000h" will keep data to 1000 hours
scylla_monitoring_retention: "14d"

# Other scylla monitoring parameters used with start-all.sh
# Other scylla monitoring parameters used with start-all.sh.
# If '-M <Scylla Manager version>' is not explicitly specified and if inventory has a 'scylla-manager' section, a Scylla Manager
# dashboard version will be auto-selected according to a version installed on the first host from the 'scylla-manager' inventory section.
# scylla_monitoring_params: '-M 2.1 -a P@ssw0rd123'

### The following settings are only relevant for non-dockerized setup
Expand Down
23 changes: 23 additions & 0 deletions ansible-scylla-monitoring/tasks/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,26 @@
dest: "{{ scylla_monitoring_config_path }}/rule_config.yml"
mode: '0644'
when: rule_config_stat.stat.exists|bool == false

- name: Set _scylla_monitoring_params to scylla_monitoring_params
set_fact:
_scylla_monitoring_params: "{{ scylla_monitoring_params | default('') }}"

- name: Auto detect Scylla Manager version
block:
- name: Get Scylla Manager version
shell: |
sctool version | grep ^Server | tr -d ' ' | cut -d':' -f2- | cut -d'.' -f1,2
delegate_to: "{{ groups['scylla-manager'][0] }}"
register: _sm_version_out

- name: Adding Scylla Manager dashboard option if getting a Manager version was successful
set_fact:
_scylla_monitoring_params: "{{ _scylla_monitoring_params }} -M {{ _sm_version_out.stdout }}"
when: _sm_version_out.rc == 0

- name: Error out if failed to get Scylla Manager version
fail:
msg: "Can't auto-detect Scylla Manager dashboard version. Either specify it explicitly or install Scylla Manager Server on the Scylla Manager host."
when: _sm_version_out.rc != 0
when: _scylla_monitoring_params is not search("-M\s+") and 'scylla-manager' in groups and (groups['scylla-manager']|length > 0)
8 changes: 4 additions & 4 deletions ansible-scylla-monitoring/tasks/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
ignore_errors: true

# Workaround for potential inner networking issue under docker
Expand Down Expand Up @@ -73,7 +73,7 @@
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
environment:
SCYLLA_USER: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_username }}{% endif %}"
SCYLLA_PSSWD: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_password }}{% endif %}"
Expand Down Expand Up @@ -101,7 +101,7 @@
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
ignore_errors: true
become: true

Expand Down Expand Up @@ -130,7 +130,7 @@
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
-R {{ scylla_monitoring_prom_rules_path }}/ \
-b --storage.tsdb.retention.time={{ scylla_monitoring_retention }} \
{{ scylla_monitoring_params | default('') }}
{{ _scylla_monitoring_params }}
become: true
environment:
SCYLLA_USER: "{% if monitoring_cql_username is defined and monitoring_cql_password is defined %}{{ monitoring_cql_username }}{% endif %}"
Expand Down

0 comments on commit 0d0ae27

Please sign in to comment.