2020-10-24 07:04:22 -05:00
|
|
|
|
---
|
|
|
|
|
- name: Install redis
|
|
|
|
|
package:
|
|
|
|
|
name: redis
|
|
|
|
|
state: present
|
|
|
|
|
|
|
|
|
|
- name: 'Create /var/db/redis-{{ redis_instance }}'
|
|
|
|
|
file:
|
|
|
|
|
path: '/var/db/redis-{{ redis_instance }}'
|
|
|
|
|
state: directory
|
|
|
|
|
owner: redis
|
|
|
|
|
group: redis
|
|
|
|
|
mode: 0700
|
|
|
|
|
|
|
|
|
|
- name: 'Create /var/run/redis-{{ redis_instance }}'
|
|
|
|
|
file:
|
|
|
|
|
path: '/var/run/redis-{{ redis_instance }}'
|
|
|
|
|
state: directory
|
|
|
|
|
owner: redis
|
|
|
|
|
group: '{{ redis_client_group }}'
|
|
|
|
|
mode: 0750
|
|
|
|
|
|
|
|
|
|
- name: 'Add /var/log/redis-{{ redis_instance }} to fstab'
|
|
|
|
|
mount:
|
|
|
|
|
path: /var/log/redis-{{ redis_instance }}
|
|
|
|
|
src: tmpfs
|
|
|
|
|
fstype: tmpfs
|
|
|
|
|
opts: 'rw,size={{ redis_log_size }},mode={{ redis_log_mode }},uid={{ redis_log_uid }},gid={{ redis_log_gid }},late'
|
|
|
|
|
state: mounted
|
|
|
|
|
|
|
|
|
|
- name: 'Create redis-{{ redis_instance }} service directories'
|
|
|
|
|
file:
|
2022-07-03 19:54:03 -05:00
|
|
|
|
path: '{{ s6_etc_dir }}/service/redis-{{ redis_instance}}{{ item }}'
|
2020-10-24 07:04:22 -05:00
|
|
|
|
state: directory
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
mode: 0755
|
|
|
|
|
with_items: '{{ redis_service_dirs }}'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
- 'Restart redis-{{ redis_instance }} log'
|
|
|
|
|
- 'Restart redis-{{ redis_instance }}'
|
|
|
|
|
|
|
|
|
|
- name: 'Generate redis-{{ redis_instance }} service scripts'
|
|
|
|
|
template:
|
2022-07-03 19:54:03 -05:00
|
|
|
|
dest: '{{ s6_etc_dir }}/service/redis-{{ redis_instance }}{{ item }}'
|
2020-10-24 07:04:22 -05:00
|
|
|
|
src: 'redis{{ item }}.j2'
|
|
|
|
|
mode: 0555
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
with_items: '{{ redis_service_scripts }}'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
- 'Restart redis-{{ redis_instance }} log'
|
|
|
|
|
- 'Restart redis-{{ redis_instance }}'
|
|
|
|
|
|
|
|
|
|
- name: 'Generate redis-{{ redis_instance }} service configuration'
|
|
|
|
|
copy:
|
2022-07-03 19:54:03 -05:00
|
|
|
|
dest: '{{ s6_etc_dir }}/service/redis-{{ redis_instance}}{{ item.name }}'
|
2020-10-24 07:04:22 -05:00
|
|
|
|
content: '{{ item.content }}'
|
|
|
|
|
mode: 0444
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
loop_control:
|
|
|
|
|
label: 'redis-{{ redis_instance }}{{ item.name }} = {{ item.content }}'
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
- 'Restart redis-{{ redis_instance }} log'
|
|
|
|
|
- 'Restart redis-{{ redis_instance }}'
|
|
|
|
|
with_items: '{{ redis_service_config }}'
|
|
|
|
|
|
|
|
|
|
- name: 'Configure redis-{{ redis_instance }}'
|
|
|
|
|
template:
|
|
|
|
|
dest: '/usr/local/etc/redis-{{ redis_instance }}.conf'
|
|
|
|
|
src: redis.conf.j2
|
|
|
|
|
mode: 0444
|
|
|
|
|
owner: root
|
|
|
|
|
group: wheel
|
|
|
|
|
notify:
|
|
|
|
|
- 'Restart redis-{{ redis_instance }}'
|
|
|
|
|
|
|
|
|
|
- name: Flush handlers
|
|
|
|
|
meta: flush_handlers
|
|
|
|
|
|
|
|
|
|
- name: 'Start redis-{{ redis_instance }}'
|
2022-07-03 19:54:03 -05:00
|
|
|
|
command: 'fdmove -c 2 1 s6-rc -l {{ s6_live_dir }} -u -v 2 -t 15000 change redis-{{ redis_instance }}'
|
2020-10-24 07:04:22 -05:00
|
|
|
|
register: change
|
|
|
|
|
changed_when: change.stdout | length > 0
|
|
|
|
|
|
|
|
|
|
- name: 'Enable redis-{{ redis_instance }}'
|
|
|
|
|
lineinfile:
|
2022-07-03 19:54:03 -05:00
|
|
|
|
path: '{{ s6_etc_dir }}/service/enabled/contents'
|
2020-10-24 07:04:22 -05:00
|
|
|
|
regexp: "^redis-{{ redis_instance }}$"
|
|
|
|
|
line: 'redis-{{ redis_instance }}'
|
|
|
|
|
state: present
|
|
|
|
|
notify:
|
|
|
|
|
- Reload s6-rc
|
|
|
|
|
|
|
|
|
|
- name: Flush handlers (again)
|
|
|
|
|
meta: flush_handlers
|