Skip to content

Commit

Permalink
scylla-node: implement a default repository selection
Browse files Browse the repository at this point in the history
Let's set a Scylla repository to the one that corresponds to Scylla version
that needs to be installed according to a scylla_version value in case a repository
is not explicitly specified.

Fixes #290

Signed-off-by: Vlad Zolotarov <[email protected]>
  • Loading branch information
vladzcloudius committed Sep 28, 2023
1 parent c702398 commit 89c5875
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ansible-scylla-node/defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -103,13 +103,15 @@ firewall_enabled: false

# URL of an RPM .repo file or a DEB .list file
# deprecated in favour of below, it will be dropped soon, below should be used
scylla_repos:
- http://downloads.scylladb.com/rpm/centos/scylla-2021.1.repo

scylla_deb_repos:
- http://downloads.scylladb.com/deb/ubuntu/scylla-2021.1.list

scylla_rpm_repos: "{{ scylla_repos }}"
#scylla_repos:
# - http://downloads.scylladb.com/rpm/centos/scylla-2021.1.repo
#
# Both scylla_deb_repos and scylla_rpm_repos, if undefined, would resolve to a URL that corresponds
# to a scylla version to which scylla_version resolves to.
#scylla_deb_repos:
# - http://downloads.scylladb.com/deb/ubuntu/scylla-2021.1.list
#
#scylla_rpm_repos: "{{ scylla_repos }}"

# Use a newer kernel from ELRepo (was recommended for RHEL/CentOS until 5.11)
# Reboot after the elrepo kernel has been installed is recommended as well.
Expand Down
3 changes: 3 additions & 0 deletions ansible-scylla-node/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@
msg: "Latest Scylla version can only be installed with an 'online' installation"
when: scylla_version == 'latest' and install_type != 'online'

- name: Set a repository URL if not explicitly set
include_tasks: set_default_repo.yml

# Upgrade
- name: Upgrade Scylla
include_tasks: upgrade/main.yml
Expand Down
32 changes: 32 additions & 0 deletions ansible-scylla-node/tasks/set_default_repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
---
- name: Split {{ scylla_version_to_install }}
set_fact:
_split_version: "{{ scylla_version_to_install.split('.') }}"

- name: Check that {{ scylla_version_to_install }} has a valid format
fail:
msg: "scylla_version resolved to {{ scylla_version_to_install }} and it can't be used with undefined scylla_deb_repos. See README.md for more details."
when: (_split_version|length < 2)

- name: Set default repository for a Debian host
block:
- name: Set temporary fact
set_fact:
_scylla_repo_default: "http://downloads.scylladb.com/deb/ubuntu/scylla-{{ _split_version[0] }}.{{ _split_version[1] }}.list"

- name: Set scylla_deb_repos
set_fact:
scylla_deb_repos: [ "{{ _scylla_repo_default }}" ]
when: ansible_os_family|lower == 'debian' and scylla_deb_repos is not defined

- name: Set default repository for a RedHat host
block:
- name: Set temporary fact
set_fact:
_scylla_repo_default: "http://downloads.scylladb.com/rpm/centos/scylla-{{ _split_version[0] }}.{{ _split_version[1] }}.repo"

- name: Set scylla_rpm_repos
set_fact:
scylla_rpm_repos: [ "{{ _scylla_repo_default }}" ]
when: ansible_os_family|lower == 'redhat' and scylla_rpm_repos is not defined

0 comments on commit 89c5875

Please sign in to comment.