ansible-roles/redis/tasks/main.yml

98 lines
1.9 KiB
YAML

---
- set_fact:
redis_restart_handler_name: "{{ redis_restart_if_needed | ternary('restart redis', 'restart redis (noop)') }}"
- name: Redis is installed.
apt:
name: "{{ item }}"
state: present
with_items:
- redis-server
- redis-tools
tags:
- redis
- packages
- name: Get Redis version
shell: "redis-server -v | grep -Eo '(v=\\S+)' | cut -d'=' -f 2 | grep -E '^([0-9]|\\.)+$'"
changed_when: false
check_mode: no
register: _redis_installed_version
tags:
- redis
- set_fact:
redis_installed_version: "{{ _redis_installed_version.stdout }}"
check_mode: no
tags:
- redis
- include: instances.yml
when: redis_instance_name is defined
- name: Redis is configured.
template:
src: redis.conf.j2
dest: "{{ redis_conf_path }}"
mode: "0644"
notify: "{{ redis_restart_handler_name }}"
when: redis_instance_name is not defined
tags:
- redis
- name: Redis is running and enabled on boot.
systemd:
name: "{{ redis_daemon }}"
enabled: yes
state: started
when: redis_instance_name is not defined
tags:
- redis
- name: Is Munin installed
stat:
path: /etc/munin/plugins
register: _munin_installed
tags:
- redis
- munin
- include: munin.yml
when:
- _munin_installed.stat.exists
- _munin_installed.stat.isdir
- redis_instance_name is not defined
tags:
- redis
- munin
- include: munin-instances.yml
when:
- _munin_installed.stat.exists
- _munin_installed.stat.isdir
- redis_instance_name is defined
tags:
- redis
- munin
- name: is NRPE present ?
stat:
path: /etc/nagios/nrpe.d/evolix.cfg
check_mode: no
register: nrpe_evolix_config
tags:
- redis
- nrpe
- include: nrpe_stretch.yml
when: ansible_distribution_release == "stretch" and nrpe_evolix_config.stat.exists == true
tags:
- redis
- nrpe
- name: Force restart redis
command: /bin/true
notify: restart redis
when: redis_restart_force