mirror of
https://gitea.0xace.cc/ansible-galaxy/redis.git
synced 2024-11-25 07:57:24 +00:00
43 lines
943 B
YAML
43 lines
943 B
YAML
---
|
|
- name: Check if redis is running
|
|
command: systemctl status redis-server
|
|
ignore_errors: yes
|
|
changed_when: False
|
|
register: service_redis_status
|
|
failed_when: False
|
|
|
|
- block:
|
|
- name: Ensure redis config exists
|
|
copy:
|
|
content: ""
|
|
dest: "/etc/redis/redis.conf"
|
|
force: no
|
|
owner: redis
|
|
group: redis
|
|
mode: 0640
|
|
|
|
- name: Template redis config
|
|
blockinfile:
|
|
block: "{{ lookup('template', 'etc/redis/redis.conf.j2') }}"
|
|
path: "/etc/redis/redis.conf"
|
|
notify:
|
|
- Restart redis
|
|
|
|
when: service_redis_status.rc != 0
|
|
|
|
- name: Ensure redis auth config exists
|
|
copy:
|
|
content: ""
|
|
dest: "/etc/redis/redis-auth.conf"
|
|
force: no
|
|
owner: redis
|
|
group: redis
|
|
mode: 0640
|
|
|
|
- name: Template redis auth config
|
|
blockinfile:
|
|
block: "{{ lookup('template', 'etc/redis/redis-auth.conf.j2') }}"
|
|
path: "/etc/redis/redis-auth.conf"
|
|
notify:
|
|
- Restart redis
|