Skip to content

Commit

Permalink
scylla role: support for 2022.2 (5.0)
Browse files Browse the repository at this point in the history
  • Loading branch information
tarzanek committed Mar 3, 2023
1 parent 8191e71 commit 4e4c1d8
Show file tree
Hide file tree
Showing 5 changed files with 113 additions and 49 deletions.
5 changes: 1 addition & 4 deletions ansible-scylla-node/meta/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,17 @@ galaxy_info:
description: Scylla node role
company: "ScyllaDB.com"
license: "license (Apache)"
min_ansible_version: 2.8.0
min_ansible_version: 6.7.0
platforms:
- name: EL
versions:
- 7
- name: Debian
versions:
- 8
- 9
- name: Ubuntu
versions:
- 20.04
- 16.04
- 18.04
- galaxy_tags:
- scylla
- scylladb
Expand Down
74 changes: 48 additions & 26 deletions ansible-scylla-node/tasks/Debian_install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,30 @@
# Requires a 'scylla_version_to_install' fact to be set to a version string we want to install
- name: Install Scylla
block:
- name: Install 'latest' Scylla

- name: Install 'latest' {{ scylla_edition }} Scylla
block:
- block:
- name: Nuke an OSS pin file if exists
- name: Nuke an {{ scylla_edition }} pin file if exists
file:
state: absent
path: /etc/apt/preferences.d/99-scylla
path: "/etc/apt/preferences.d/99-{{ scylla_package_prefix }}"

- name: Install latest OSS Scylla
- name: Install latest {{ scylla_edition }} Scylla
apt:
name: scylla
name: "{{ scylla_package_prefix }}"
state: latest
when: scylla_edition == 'oss'

- block:
- name: Nuke an Enterprise pin file if exists
file:
state: absent
path: /etc/apt/preferences.d/99-scylla-enterprise

- name: Install latest Enterprise Scylla
- name: Install latest {{ scylla_edition }} Scylla machine image
apt:
name: scylla-enterprise
name: "{{ scylla_package_prefix }}-machine-image"
state: latest
when: scylla_edition == 'enterprise'

when: scylla_version_to_install == 'latest'

### Handle non-latest version installation
- name: Install explicitly specified Scylla version
block:
- name: Set Scylla package prefix as OSS
set_fact:
scylla_package_prefix: "scylla"
when: scylla_edition == 'oss'

- name: Set Scylla package prefix as Enterprise
set_fact:
scylla_package_prefix: "scylla-enterprise"
when: scylla_edition == 'enterprise'

- name: Get versions of {{ scylla_edition }} package
# 'apt list -a' output has a package version as a second column and an arch as a third one.
Expand All @@ -57,7 +42,7 @@

- name: "Validate scylla version correctness"
ansible.builtin.fail:
msg: "Too many/few choices for a requested version '{{ scylla_version_to_install }}': {{ aptversions.stdout_lines }}. Bailing out!"
msg: "Too many/few choices for a requested version '{{ scylla_version_to_install }}': {{ aptversions.stdout_lines }}. Fix your Scylla scylla_version or scylla_deb_repos/scylla_repo_keys!"
when: aptversions.stdout_lines | length != 1

- name: Fetch version parts of Scylla package
Expand All @@ -75,10 +60,47 @@
group: root
mode: '0644'

- name: "Install {{ aptversions.stdout }}"
- name: "Install {{ aptversions.stdout }} {{ scylla_edition }}"
apt:
name: "{{ scylla_package_prefix }}={{ aptversions.stdout }}"
state: present
allow_downgrade: yes


# strip scylla_version_to_install off the last .XXX only to format 2022.2.0-20230112

# scylla:
# 2022.2.0-0.20230112.4f0f82ff2e1d-1
# scylla machine image:
# 2022.2.0-20230112.1239c34-1

- name: Get versions of {{ scylla_edition }} machine image package
# 'apt list -a' output has a package version as a second column and an arch as a third one.
# Let's filter by the arch first and then cut the version column.
# Then we will filter out all rows that start with a requested version string followed by a digit to filter out version like 2021.1.11 when 2021.1.1 was requested.
# And finally, we are going to get rid of duplications.
shell: apt list -a {{ scylla_package_prefix }}-machine-image 2>/dev/null | awk '{split($0,a," "); print a[2]}' | egrep "^{{ stripped_scylla_machine_image_version_escaped }}" | sort | uniq
register: aptversions_machine_image
vars:
stripped_scylla_machine_image_version_escaped: "{{ scylla_version_split[0][0] | regex_escape }}\\-"

- name: "Validate scylla version correctness"
ansible.builtin.fail:
msg: "Too many/few choices for a requested version '{{ stripped_scylla_machine_image_version_escaped }}': {{ aptversions_machine_image.stdout_lines }}. Fix your Scylla scylla_version or scylla_deb_repos/scylla_repo_keys!"
when: aptversions_machine_image.stdout_lines | length != 1

- name: Fetch version parts of Scylla package
set_fact:
scylla_machine_image_version_split: "{{ aptversions_machine_image.stdout | regex_findall(regexp, ignorecase=True) }}"
vars:
# All we know that the version is a string comprised of 3 parts separated by '-'
regexp: '^([^\-]+)-([^\-]+)-([^\-]+)$'

- name: "Install {{ aptversions_machine_image.stdout }} {{ scylla_edition }} machine image"
apt:
name: "{{ scylla_package_prefix }}-machine-image={{ aptversions_machine_image.stdout }}*"
state: latest
allow_downgrade: yes

when: scylla_version_to_install != 'latest'
become: true
28 changes: 15 additions & 13 deletions ansible-scylla-node/tasks/RedHat.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,34 +82,36 @@
when: item.split(".")[-1] == "repo"
become: true

- name: Install Scylla
- name: Install {{ scylla_edition }}
block:
- name: Install latest OSS Scylla
- name: Install latest {{ scylla_edition }} Scylla
yum:
name: scylla
name: "{{ scylla_package_prefix }}"
state: latest
lock_timeout: 60
when: scylla_version == 'latest' and scylla_edition == 'oss'
when: scylla_version == 'latest'

- name: Install latest Enterprise Scylla
- name: Install latest {{ scylla_edition }} Scylla machine image
yum:
name: scylla-enterprise
name: "{{ scylla_package_prefix }}-machine-image"
state: latest
when: scylla_version == 'latest' and scylla_edition == 'enterprise'
lock_timeout: 60
when: scylla_version == 'latest'

- name: Install specified OSS Scylla
- name: Install specified {{ scylla_edition }} Scylla
yum:
name: "scylla-{{ scylla_version }}"
name: "{{ scylla_package_prefix }}-{{ scylla_version }}"
state: present
lock_timeout: 60
when: scylla_version != 'latest' and scylla_edition == 'oss'
when: scylla_version != 'latest'

- name: Install specified Enterprise Scylla
- name: Install specified {{ scylla_edition }} Scylla machine image
yum:
name: "scylla-enterprise-{{ scylla_version }}"
name: "{{ scylla_package_prefix }}-machine-image-{{ scylla_version }}"
state: present
lock_timeout: 60
when: scylla_version != 'latest' and scylla_edition == 'enterprise'
when: scylla_version != 'latest'

become: true

- name: Configure SELinux
Expand Down
45 changes: 39 additions & 6 deletions ansible-scylla-node/tasks/common.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,25 @@

- name: Collect IO settings for the first node of every DC
block:
- name: check for existing io_properties for cloud run
stat:
path: /etc/scylla.d/io_properties.yaml
register: io_prop_cloud_stat

- name: check for scylla_cloud_io_setup
stat:
path: /opt/scylladb/scylla-machine-image/scylla_cloud_io_setup
register: io_cloud_setup

- name: Run cloud IO setup
shell: |
/opt/scylladb/scylla-machine-image/scylla_cloud_io_setup
become: true
# if above is not found leverage /opt/scylladb/python3/bin/python3 /opt/scylladb/scylla-machine-image/lib/scylla_cloud_io_setup.py ?
# or provide our own role runner for pre 2022.2.1 ?
when: (scylla_raid_setup is defined) and (scylla_raid_setup|length > 0) and (io_cloud_setup.stat.exists) and (io_prop_stat.stat.exists|bool == False)
# we should maybe add a better way how to detect if this is cloud and run it, otherwise fallback to below (though above should fall back to it too, but it was broken in early 2022.1 and 2022.2.0)

- name: check for existing io_properties
stat:
path: /etc/scylla.d/io_properties.yaml
Expand Down Expand Up @@ -95,23 +114,37 @@
become: true
when: skip_ntp is defined and skip_ntp|bool == false

- name: check for node_exporter_install
stat:
path: /usr/sbin/node_exporter_install
register: node_exporter_install

- name: node exporter setup
shell: |
node_exporter_install --force
when: install_type == 'online'
when: (install_type == 'online') and (node_exporter_install.stat.exists)
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: check for node_exporter
stat:
path: /opt/scylladb/node_exporter/node_exporter
register: node_exporter

- name: node exporter setup from 5.0/2022
service:
block:
- name: Enforce disabling of old node exporter
service:
name: node-exporter
state: stopped
ignore_errors: true
- name: Start bundled node exporter
service:
name: scylla-node-exporter
state: started
become: true
ignore_errors: true
#TODO: stop ignoring errors when a version check is added
when: node_exporter.stat.exists

- name: configure Scylla
shell: |
Expand Down
10 changes: 10 additions & 0 deletions ansible-scylla-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,16 @@
package_facts:
manager: auto

- name: Set Scylla package prefix as OSS
set_fact:
scylla_package_prefix: "scylla"
when: scylla_edition == 'oss'

- name: Set Scylla package prefix as Enterprise
set_fact:
scylla_package_prefix: "scylla-enterprise"
when: scylla_edition == 'enterprise'

# Upgrade
- name: Upgrade Scylla
include_tasks: upgrade/main.yml
Expand Down

0 comments on commit 4e4c1d8

Please sign in to comment.