ansible-roles/redis/tasks/main.yml

98 lines
1.9 KiB
YAML
Raw Normal View History

2016-09-29 10:59:13 +02:00
---
- set_fact:
redis_restart_handler_name: "{{ redis_restart_if_needed | ternary('restart redis', 'restart redis (noop)') }}"
- name: Redis is installed.
2016-09-29 10:59:13 +02:00
apt:
2017-09-27 17:57:02 +02:00
name: "{{ item }}"
state: present
2017-09-27 17:57:02 +02:00
with_items:
- redis-server
- redis-tools
tags:
- redis
- packages
2016-09-29 10:59:13 +02:00
- name: Get Redis version
2017-12-29 11:18:27 +01:00
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
2018-09-19 16:25:47 +02:00
tags:
- redis
- set_fact:
redis_installed_version: "{{ _redis_installed_version.stdout }}"
check_mode: no
2018-09-19 16:25:47 +02:00
tags:
- redis
2018-09-19 17:24:26 +02:00
- include: instances.yml
when: redis_instance_name is defined
- name: Redis is configured.
2016-09-29 10:59:13 +02:00
template:
src: redis.conf.j2
dest: "{{ redis_conf_path }}"
mode: "0644"
notify: "{{ redis_restart_handler_name }}"
2018-09-19 17:24:26 +02:00
when: redis_instance_name is not defined
tags:
- redis
2016-09-29 10:59:13 +02:00
- name: Redis is running and enabled on boot.
2018-09-19 17:24:26 +02:00
systemd:
2016-09-29 10:59:13 +02:00
name: "{{ redis_daemon }}"
enabled: yes
state: started
2018-09-19 17:24:26 +02:00
when: redis_instance_name is not defined
tags:
- redis
2017-06-02 14:25:13 +02:00
- name: Is Munin installed
stat:
path: /etc/munin/plugins
register: _munin_installed
tags:
- redis
- munin
2017-06-02 14:25:13 +02:00
- 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
2018-12-21 11:13:40 +01:00
command: /bin/true
notify: restart redis
when: redis_restart_force