Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
38 changes: 27 additions & 11 deletions roles/redis/defaults/main/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,38 @@ redis_security_packages:
# Redis install from source - boolean
# When set to 'true' Redis will be installed from source.
# Otherwise Redis will be installed from YUM.
redis_install_from_source: true
redis_install_from_source: false

# Packages required to build Redis from source
redis_build_packages:
- tar
- unzip
- gcc
- gcc-c++
- make
- systemd-devel
# The Redis repo to use - string
# Default - Redis
# Valid options are 'Redis', 'remi', 'default'.
# When set to 'default', neither the Remi or Redis.io repos will be installed and Redis
# will be installed from the repos already installed on the target and appstream can be used.
redis_yum_repo: Redis

# The Redis.io repo is used when:
# - redis_install_from_source is set to 'false'
# - common_install_yum_repos is set to 'true'
# - redis_yum_repo is set to 'Redis'
redis_redis_io_repo: /etc/yum.repos.d/redis.repo
redis_redis_io_base_url: "http://packages.redis.io/rpm/rockylinux{{ ansible_distribution_major_version }}"
redis_redis_io_gpg_key: https://packages.redis.io/gpg

# The Remi and EPEL repos are used only when:
# The Remi and EPEL repos are used when:
# - redis_install_from_source is set to 'false'
# - common_install_yum_repos is set to 'true'
# - redis_packages contains 'remi'
# - redis_yum_repo is set to 'remi'
redis_remi_repo_url: "http://rpms.remirepo.net/enterprise/remi-release-\
{{ ansible_distribution_version }}.rpm"
redis_epel_repo_url: "https://dl.fedoraproject.org/pub/epel/epel-release-latest-\
{{ ansible_distribution_major_version }}.noarch.rpm"

# The build packages are used when:
# - redis_install_from_source is set to 'true'
redis_build_packages:
- tar
- unzip
- gcc
- gcc-c++
- make
- systemd-devel
53 changes: 40 additions & 13 deletions roles/redis/tasks/install-from-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,48 @@
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Install Redis from packages
when: not offline_install_enabled | bool
when:
- not offline_install_enabled | bool
- redis_packages is defined
- redis_packages is not none
- redis_packages is iterable
block:
- name: Include tasks to install Remi repo
ansible.builtin.include_tasks:
file: install-remi-repo.yml
when:
- redis_packages is defined
- redis_packages is search('remi')
- name: Get list of yum repos (to disable temporarily) # noqa command-instead-of-module
ansible.builtin.command: yum -q repolist
register: repolist_result
changed_when: false

- name: Install Redis from packages
ansible.builtin.dnf:
name: '{{ redis_packages }}'
state: present
update_cache: true
enablerepo: "{{ redis_packages is search('remi') | ternary('remi', omit) }}"
- name: Install using Remi packages
when: redis_yum_repo == 'remi'
block:
- name: Include tasks to install Remi repo
ansible.builtin.include_tasks:
file: install-remi-repo.yml

- name: Install Redis using Remi packages
ansible.builtin.dnf:
name: '{{ redis_packages }}'
state: present
update_cache: true
enablerepo: "{{ redis_yum_repo }}"
disablerepo: "{{ repolist_result.stdout_lines[1:] | map('split', ' ')
| map('first') | list }}"

- name: Install Redis using Redis.io packages
when: redis_yum_repo == 'Redis'
block:
- name: Include tasks to install Redis.io repo
ansible.builtin.include_tasks:
file: install-redis-repo.yml

- name: Install Redis using Redis.io packages
ansible.builtin.dnf:
name: '{{ redis_packages }}'
state: installed
update_cache: true
enablerepo: "{{ redis_yum_repo }}"
disablerepo: "{{ repolist_result.stdout_lines[1:] | map('split', ' ')
| map('first') | list }}"

- name: Install Redis from packages (offline)
ansible.builtin.import_role:
Expand Down
20 changes: 20 additions & 0 deletions roles/redis/tasks/install-redis-repo.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# Copyright (c) 2024, Itential, Inc
# GNU General Public License v3.0+ (see LICENSE or https://www.gnu.org/licenses/gpl-3.0.txt)
---
- name: Install Redis.io repo and GPG key
when:
- common_install_yum_repos | bool
- redis_yum_repo == 'Redis'
block:
- name: Install Redis.io repo
ansible.builtin.template:
src: "redis.repo.j2"
dest: "{{ redis_redis_io_repo }}"
owner: root
group: root
mode: "0644"

- name: Import DNF repository GPG key
ansible.builtin.rpm_key:
state: present
key: "{{ redis_redis_io_gpg_key }}"
3 changes: 1 addition & 2 deletions roles/redis/tasks/install-remi-repo.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
- name: Install Remi-related repos
when:
- common_install_yum_repos | bool
- redis_packages is defined
- redis_packages is search('remi')
- redis_yum_repo == 'remi'
block:
- name: Install EPEL repo
ansible.builtin.dnf:
Expand Down
18 changes: 14 additions & 4 deletions roles/redis/tasks/validate-vars.yml
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,20 @@
- redis_source_url is not defined
- redis_install_from_source | bool

- name: Set redis_packages to the default value when not defined in inventory
ansible.builtin.set_fact:
redis_packages: "{{ redis_packages_default[ansible_distribution_major_version] }}"
- name: Set the Redis packages
when:
- redis_packages is not defined
- not redis_install_from_source | bool
block:
- name: Set redis_packages to the Remi default value when not defined in inventory
ansible.builtin.set_fact:
redis_packages: "{{ redis_remi_packages_default[ansible_distribution_major_version] }}"
when: redis_yum_repo == 'remi'

- name: Set redis_packages to the Redis.io default value when not defined in inventory
ansible.builtin.set_fact:
redis_packages: "{{ redis_redis_io_packages_default[ansible_distribution_major_version] }}"
when: redis_yum_repo == 'Redis'

- name: Print Redis installation details
when: not offline_install_enabled | bool
Expand All @@ -110,7 +118,9 @@

- name: Print Redis installation details when installing from repo
ansible.builtin.debug:
msg: "Redis packages: {{ redis_packages }}"
msg:
- "Redis packages: {{ redis_packages }}"
- "Redis yum repo: {{ redis_yum_repo }}"
when: not redis_install_from_source | bool

- name: Print Redis installation details (offline)
Expand Down
5 changes: 5 additions & 0 deletions roles/redis/templates/redis.repo.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[Redis]
name=Redis
baseurl={{ redis_redis_io_base_url }}
enabled=1
gpgcheck=1
15 changes: 13 additions & 2 deletions roles/redis/vars/platform-release-6.0.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,19 @@
---
# The keys represent the EL major version (ansible_distribution_major_version)

# The redis_packages_default is used when the redis_install_from_source is set to 'false'
redis_packages_default:
# The redis_redis_io_packages_default is used when the redis_install_from_source is set to 'false'
# and redis_yum_repo is 'Redis'
redis_redis_io_packages_default:
"8":
- "redis"
"9":
- "redis"
"2023":
- "redis"

# The redis_remi_packages_default is used when the redis_install_from_source is set to 'false'
# and redis_yum_repo is 'remi'
redis_remi_packages_default:
"8":
- "@redis:remi-7.2"
"9":
Expand Down
Loading