mirror of
https://gitea.0xace.cc/ansible-galaxy/redis.git
synced 2024-11-25 16:06:39 +00:00
51 lines
1.2 KiB
YAML
51 lines
1.2 KiB
YAML
|
---
|
||
|
- name: Set fact about redis master
|
||
|
set_fact:
|
||
|
redis_master_ip: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address }}"
|
||
|
delegate_to: "{{ item }}"
|
||
|
loop: "{{ play_hosts }}"
|
||
|
run_once: yes
|
||
|
when: hostvars[inventory_hostname].master is defined
|
||
|
|
||
|
- debug:
|
||
|
msg: "{{ redis_master_ip }}"
|
||
|
|
||
|
- name: Include redis installation tasks
|
||
|
include: "{{ ansible_os_family }}/install.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
|
||
|
|
||
|
- name: Configure redis
|
||
|
include: configure.yaml
|
||
|
when: service_redis_status.rc != 0
|
||
|
|
||
|
- name: Start redis server
|
||
|
service:
|
||
|
name: redis-server
|
||
|
enabled: True
|
||
|
state: started
|
||
|
masked: no
|
||
|
|
||
|
- name: Check if redis-sentinel is running
|
||
|
command: systemctl status redis-sentinel
|
||
|
ignore_errors: yes
|
||
|
changed_when: False
|
||
|
register: service_redis_sentinel_status
|
||
|
failed_when: False
|
||
|
|
||
|
- name: Configure redis-sentinel
|
||
|
include: configure-sentinel.yaml
|
||
|
when: service_redis_sentinel_status.rc != 0
|
||
|
|
||
|
- name: Start redis-sentinel
|
||
|
service:
|
||
|
name: redis-sentinel
|
||
|
enabled: True
|
||
|
state: started
|
||
|
masked: no
|