Skip to content
This repository has been archived by the owner on May 23, 2024. It is now read-only.

fix: do not overwrite redis server configuration #117

Merged
merged 1 commit into from
Sep 20, 2023
Merged
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
35 changes: 18 additions & 17 deletions tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,46 +126,47 @@
owner: "{{ redis_user }}"
group: "{{ redis_group }}"

- name: Configure Redis.
become: yes
ansible.builtin.template:
src: redis.conf.j2
dest: "{{ redis_server_configuration_file }}"
mode: 0640
owner: "{{ redis_user }}"
group: "{{ redis_group }}"
notify: Restart Redis Server

- name: Add Ansible begin marker for backwards compatibility
ansible.builtin.lineinfile:
line: "# BEGIN ANSIBLE MANAGED BLOCK"
path: "{{ redis_sentinel_configuration_file }}"
path: "{{ item }}"
insertbefore: BOF
create: true
mode: 0600
mode: "0600"
owner: "{{ redis_user }}"
group: "{{ redis_group }}"
loop:
- "{{ redis_sentinel_configuration_file }}"
- "{{ redis_server_configuration_file }}"

- name: Add Ansible end marker for backwards compatibility
ansible.builtin.lineinfile:
line: "# END ANSIBLE MANAGED BLOCK"
path: "{{ redis_sentinel_configuration_file }}"
path: "{{ item }}"
insertbefore: "# Generated by CONFIG REWRITE"
create: true
mode: 0600
mode: "0600"
owner: "{{ redis_user }}"
group: "{{ redis_group }}"
loop:
- "{{ redis_sentinel_configuration_file }}"
- "{{ redis_server_configuration_file }}"

- name: Configure Sentinel
- name: Configure Redis and Sentinel.
become: yes
ansible.builtin.blockinfile:
block: "{{ lookup('ansible.builtin.template', 'sentinel.conf.j2') }}"
path: "{{ redis_sentinel_configuration_file }}"
block: "{{ lookup('ansible.builtin.template', item.template_file) }}"
path: "{{ item.path }}"
insertbefore: "# Generated by CONFIG REWRITE"
create: true
mode: 0600
owner: "{{ redis_user }}"
group: "{{ redis_group }}"
notify: Restart Redis Sentinel
notify: Restart Redis Server
loop:
- { template_file: "redis.conf.j2", path: "{{ redis_server_configuration_file }}" }
- { template_file: "sentinel.conf.j2", path: "{{ redis_sentinel_configuration_file }}" }

- name: Create Redis Lib Directory.
become: yes
Expand Down
14 changes: 7 additions & 7 deletions templates/redis.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ supervised no
daemonize yes
pidfile "/var/run/redis/redis-server.pid"
logfile "{{ redis_server_log_file_path }}"
loglevel "{{ redis_log_level }}"
dir /var/lib/redis/
loglevel {{ redis_log_level }}
dir "/var/lib/redis/"
bind {{ redis_instance_ip }}
port 6379

Expand All @@ -24,15 +24,15 @@ save 900 1
save 300 10
save 60 10000

rdbcompression "yes"
rdbcompression yes

dbfilename dump.rdb
dbfilename "dump.rdb"

appendonly "no"
appendfsync "everysec"
appendonly no
appendfsync everysec
no-appendfsync-on-rewrite no

protected-mode "{{ redis_protected_mode }}"
protected-mode {{ redis_protected_mode }}

{% if redis_instance_type == "replica" %}
replicaof {{ redis_master_instance_ip }} 6379
Expand Down