-
Notifications
You must be signed in to change notification settings - Fork 10
/
redis.yaml
76 lines (67 loc) · 1.97 KB
/
redis.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
- name: Remove existing Redis keyring file
ansible.builtin.file:
path: /usr/share/keyrings/redis-archive-keyring.gpg
state: absent
become: true
- name: Add Redis GPG Key
ansible.builtin.shell:
cmd: |
set -o pipefail # See: https://ansible.readthedocs.io/projects/lint/rules/risky-shell-pipe/#correct-code
curl -fsSL https://packages.redis.io/gpg | sudo gpg --batch --dearmor -o /usr/share/keyrings/redis-archive-keyring.gpg
executable: /bin/bash
become: true
- name: Add Redis APT Repository
ansible.builtin.shell:
cmd: |
set -o pipefail # See: https://ansible.readthedocs.io/projects/lint/rules/risky-shell-pipe/#correct-code
echo "deb [signed-by=/usr/share/keyrings/redis-archive-keyring.gpg] https://packages.redis.io/deb $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/redis.list
executable: /bin/bash
become: true
- name: Ensure Redis data directory exists
ansible.builtin.file:
path: "{{ redis_data_directory }}"
state: directory
owner: redis
group: redis
mode: "0755"
become: true
- name: Install redis
ansible.builtin.apt:
name: redis
state: present
update_cache: true
become: true
- name: Copy the redis systemd service file
become: true
ansible.builtin.copy:
content: |
[Unit]
Description=Redis
After=syslog.target
[Service]
ExecStart=/usr/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
Restart=on-success
[Install]
WantedBy=multi-user.target
dest: /etc/systemd/system/redis.service
owner: root
group: root
mode: "0644"
register: _redis_service
- name: Ensure Redis Configuration
ansible.builtin.template:
src: templates/redis.conf.j2
dest: /etc/redis/redis.conf
owner: root
group: root
mode: "0644"
become: true
notify: Restart services redis
- name: Ensure Redis is started
ansible.builtin.service:
name: redis
state: started
enabled: "yes"
become: true