Skip to content

Commit

Permalink
scylla-monitoring: auto-detect Scylla dashboard version
Browse files Browse the repository at this point in the history
Auto-detect Scylla version when scylla_monitoring_dashboards_versions is not specified
or is empty.

Scylla must be installed on the first host from the 'scylla' section in the inventory for
auto-detection to succeed.

Signed-off-by: Vlad Zolotarov <[email protected]>
  • Loading branch information
vladzcloudius committed Mar 13, 2024
1 parent 0d0ae27 commit 56aba49
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
7 changes: 4 additions & 3 deletions ansible-scylla-monitoring/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,10 @@ scylla_monitoring_alertdata_path: "{{ scylla_monitoring_deploy_path }}/alertdata
# will use the information from the inventory to generate scylla_servers.yml.
use_nodetool_status_with_genconfig: false

# List of monitoring dashboards to enable
scylla_monitoring_dashboards_versions:
- '2021.1'
# List of monitoring dashboards to enable. If empty or not set the Role will auto-select the one that corresponds to a
# Scylla version installed on the first host from the 'scylla' inventory section.
#scylla_monitoring_dashboards_versions:
# - '2021.1'

# Username which will be used for the cql plugin if auth is enabled on scylla-server side
# scylla_monitoring_cql_default_user: 'scylla_cql_monitor'
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 @@ -240,3 +240,26 @@
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)

- name: Set _scylla_monitoring_dashboards_versions to scylla_monitoring_dashboards_versions
set_fact:
_scylla_monitoring_dashboards_versions: "{{ scylla_monitoring_dashboards_versions | default([]) }}"

- name: Auto detect Scylla version if dashboard versions were not explicitly specified
block:
- name: Get Scylla version from the first Scylla node
shell: |
scylla --version | cut -d'.' -f1,2
delegate_to: "{{ groups['scylla'][0] }}"
register: _scylla_version_out

- name: Adding Scylla dashboard option if getting a Scylla version was successful
set_fact:
_scylla_monitoring_dashboards_versions: ["{{ _scylla_version_out.stdout }}"]
when: _scylla_version_out.rc == 0

- name: Error out if failed to get Scylla version
fail:
msg: "Can't auto-detect Scylla dashboard version. Either specify it explicitly or install scylla on the first Scylla node."
when: _scylla_version_out.rc != 0
when: (_scylla_monitoring_dashboards_versions|length == 0) and 'scylla' in groups and (groups['scylla']|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 @@ -39,7 +39,7 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
Expand Down Expand Up @@ -67,7 +67,7 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
Expand Down Expand Up @@ -95,7 +95,7 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
Expand Down Expand Up @@ -124,7 +124,7 @@
./start-all.sh \
-d {{ scylla_monitoring_data_path }} \
-f {{ scylla_monitoring_alertdata_path }} \
-v {{ scylla_monitoring_dashboards_versions|join(',') }} \
-v {{ _scylla_monitoring_dashboards_versions|join(',') }} \
-s {{ scylla_monitoring_config_path }}/scylla_servers.yml \
-N {{ scylla_monitoring_config_path }}/scylla_manager_servers.yml \
-r {{ scylla_monitoring_config_path }}/rule_config.yml \
Expand Down

0 comments on commit 56aba49

Please sign in to comment.