This commit is contained in:
2023-04-06 11:53:54 +02:00
parent 912ec16cdb
commit 12c86849c2
59 changed files with 1065 additions and 102 deletions

View File

@ -1,11 +1,17 @@
---
- name: (redis-server.yml) Set var '_redis_conf'
set_fact:
_redis_conf: "{{ '/etc/redis.conf' if ansible_distribution == 'CentOS' else '/etc/redis/redis.conf' }}"
- name: (redis-server.yml) update
apt:
update_cache: true
cache_valid_time: "{{ 0 if apt_config_updated is defined and apt_config_updated.changed else apt_update_cache_valid_time }}"
when: apt_update|bool
when:
- ansible_facts['distribution'] == "Debian"
- apt_update|bool
tags:
- redis-server
@ -17,7 +23,9 @@
warn: false
changed_when: _dpkg_configure.stdout_lines | length
register: _dpkg_configure
when: apt_dpkg_configure|bool
when:
- ansible_facts['distribution'] == "Debian"
- apt_update|bool
tags:
- redis-server
@ -27,15 +35,30 @@
upgrade: "{{ apt_upgrade_type }}"
update_cache: true
dpkg_options: "{{ apt_upgrade_dpkg_options | join(',') }}"
when: apt_upgrade|bool
when:
- ansible_facts['distribution'] == "Debian"
- apt_upgrade|bool
tags:
- redis-server
- name: (redis-server.yml) Install redis-server packages
- name: (redis-server.yml) Install redis-server packages (debian system)
apt:
name: redis-server
state: present
when:
- ansible_facts['distribution'] == "Debian"
tags:
- redis-server
- name: (redis-server.yml) Install redis packages (centos system)
yum:
name: redis
state: latest
update_cache: yes
when:
- ansible_os_family == "RedHat"
- ansible_distribution == "CentOS"
tags:
- redis-server
@ -79,23 +102,23 @@
tags:
- redis-server
- name: (redis-server.yml) Check if file '/etc/redis/redis.conf.ORIG' exists
- name: (redis-server.yml) Check if redis configuration file exists
stat:
path: /etc/redis/redis.conf.ORIG
path: "{{ _redis_conf }}.ORIG"
register: redis_conf_exists
tags:
- redis-server
- name: (redis-server.yml) Backup existing file /etc/redis/redis.conf.
command: cp -a /etc/redis/redis.conf /etc/redis/redis.conf.ORIG
- name: (redis-server.yml) Backup existing redis configuration file.
command: cp -a "{{ _redis_conf }}" "{{ _redis_conf }}".ORIG
when:
- redis_conf_exists.stat.exists == False
tags:
- redis-server
- name: (redis-server.yml) adjust configuration '/etc/redis/redis.conf'
- name: (redis-server.yml) adjust redis configuration
lineinfile:
dest: /etc/redis/redis.conf
dest: "{{ _redis_conf }}"
regexp: "{{ item.regexp }}"
insertafter: "{{ item.insertafter }}"
line: "{{ item.key }} {{ item.val }}"