mirror of
https://gitea.0xace.cc/ansible-galaxy/redis.git
synced 2024-11-25 16:06:39 +00:00
24 lines
756 B
YAML
24 lines
756 B
YAML
|
---
|
||
|
- name: Discover redis with master role
|
||
|
shell: redis-cli --pass {{ redis_requirepass }} info replication | grep 'role:master'
|
||
|
register: redis_master
|
||
|
changed_when: False
|
||
|
failed_when: False
|
||
|
|
||
|
- name: Set fact about redis master
|
||
|
set_fact:
|
||
|
redis_master_ip: "{{ hostvars[inventory_hostname].ansible_default_ipv4.address | default(hostvars[play_hosts[0]].ansible_default_ipv4.address) }}"
|
||
|
delegate_to: "{{ item }}"
|
||
|
delegate_facts: true
|
||
|
loop: "{{ play_hosts }}"
|
||
|
when: redis_master.rc == 0
|
||
|
|
||
|
- name: Set fact about redis master
|
||
|
set_fact:
|
||
|
redis_master_ip: "{{ hostvars[play_hosts[0]].ansible_default_ipv4.address }}"
|
||
|
when: redis_master_ip is not defined
|
||
|
|
||
|
- debug:
|
||
|
msg: "Master redis IP is {{ redis_master_ip }}"
|
||
|
verbosity: 2
|