ansible-roles/redis/tasks/main.yml
Jérémy Lecour bee57a0b3c
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone/pr Build is failing
change distribution release codename
Ansible 2.2 is too old to know about buster.
Let's use LSB for that.
2019-06-18 17:35:28 +02:00

105 lines
2.4 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
vars:
redis_daemon: "redis-server@{{ redis_instance_name }}"
redis_conf_path: "/etc/redis/redis-{{ redis_instance_name }}.conf"
redis_unixsocket: "/var/run/redis/{{ redis_instance_name }}/redis.sock"
redis_pidfile: "/var/run/redis/{{ redis_instance_name }}/{{ redis_daemon }}.pid"
redis_logfile: "/var/log/redis/{{ redis_instance_name }}/redis-server.log"
redis_dbdir: "/var/lib/redis/{{ redis_instance_name }}"
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_lsb.codename == "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