You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
85 lines
1.6 KiB
85 lines
1.6 KiB
2 years ago
|
- name: set redis_cfg
|
||
|
set_fact:
|
||
|
redis_cfg: "{{ redis_default_config | d({}) | combine(redis_config | d({}), recursive=true) }}"
|
||
|
|
||
|
|
||
|
- name: install redis
|
||
|
include_tasks: tasks/install_packages.yml
|
||
|
vars:
|
||
|
package:
|
||
|
- redis
|
||
|
- alpine: redis-openrc
|
||
|
|
||
|
|
||
|
- name: create user and group
|
||
|
include_tasks: tasks/create_user.yml
|
||
|
vars:
|
||
|
user:
|
||
|
name: "{{ redis_user }}"
|
||
|
group: "{{ redis_group }}"
|
||
|
|
||
|
|
||
|
- name: remove old redis configs
|
||
|
file:
|
||
|
path: "{{ item }}"
|
||
|
state: absent
|
||
|
loop:
|
||
|
- /etc/redis.conf
|
||
|
- /etc/sentinel.conf
|
||
|
notify: restart redis
|
||
|
|
||
|
|
||
|
- name: create redis config dir
|
||
|
file:
|
||
|
path: "{{ redis_conf_dir }}"
|
||
|
state: directory
|
||
|
mode: 0700
|
||
|
owner: "{{ redis_user }}"
|
||
|
group: "{{ redis_group }}"
|
||
|
notify: restart redis
|
||
|
|
||
|
|
||
|
- name: template redis config file
|
||
|
template:
|
||
|
src: redis.j2
|
||
|
dest: "{{ redis_conf_file }}"
|
||
|
force: yes
|
||
|
mode: 0400
|
||
|
lstrip_blocks: yes
|
||
|
owner: "{{ redis_user }}"
|
||
|
group: "{{ redis_group }}"
|
||
|
notify: restart redis
|
||
|
|
||
|
|
||
|
- name: edit service config
|
||
|
lineinfile:
|
||
|
path: /etc/conf.d/redis
|
||
|
regexp: "^{{ item.name }}="
|
||
|
line: "{{ item.name }}=\"{{ item.value }}\""
|
||
|
notify: restart redis
|
||
|
loop:
|
||
|
- name: command_user
|
||
|
value: "{{ redis_user }}:{{ redis_group }}"
|
||
|
- name: cfgfile
|
||
|
value: "{{ redis_conf_file }}"
|
||
|
|
||
|
|
||
|
- name: flush handlers
|
||
|
meta: flush_handlers
|
||
|
|
||
|
|
||
|
- name: add directories to backup plan
|
||
|
include_role:
|
||
|
name: backup
|
||
|
vars:
|
||
|
function: add
|
||
|
backup_items:
|
||
|
- "{{ redis_conf_dir }}"
|
||
|
|
||
|
|
||
|
- name: enable and start redis
|
||
|
service:
|
||
|
name: redis
|
||
|
enabled: yes
|
||
|
state: started
|