ansible-roles/redis/tasks/nrpe.yml
Jérémy Lecour 00fe225a3c
All checks were successful
Ansible Lint |Total|New|Outstanding|Fixed|Trend |:-:|:-:|:-:|:-:|:-: |2615|7|2608|177|:+1: Reference build: <a href="https://jenkins.evolix.org/job/gitea/job/ansible-roles/job/unstable/278//ansiblelint">Evolix » ansible-roles » unstable #278</a>
gitea/ansible-roles/pipeline/head This commit looks good
force: [yes,no] → force [true,false]
2023-06-28 13:25:30 +02:00

120 lines
3.2 KiB
YAML

---
- name: Install perl lib-redis (needed by check_redis)
ansible.builtin.apt:
name: libredis-perl
state: present
tags:
- redis
- nrpe
- name: install check_redis on Jessie
ansible.builtin.copy:
src: check_redis.pl
dest: /usr/local/lib/nagios/plugins/check_redis
force: true
mode: "0755"
owner: root
group: root
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version is version('9', '<')
tags:
- redis
- nrpe
- name: set the path of check_redis on Jessie
ansible.builtin.set_fact:
redis_check_redis_path: /usr/local/lib/nagios/plugins/check_redis
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version is version('9', '<')
tags:
- redis
- nrpe
- name: set the path of check_redis on Stretch and later
ansible.builtin.set_fact:
redis_check_redis_path: /usr/lib/nagios/plugins/check_redis
when:
- ansible_distribution == "Debian"
- ansible_distribution_major_version is version('9', '>=')
tags:
- redis
- nrpe
- name: sudo without password for nagios
ansible.builtin.lineinfile:
dest: /etc/sudoers.d/evolinux
regexp: 'check_redis$'
line: 'nagios ALL = NOPASSWD: {{ redis_check_redis_path }}'
insertafter: '^nagios'
validate: "visudo -cf %s"
create: yes
when: redis_instance_name is defined
tags:
- redis
- nrpe
- name: Use check_redis for NRPE
ansible.builtin.replace:
dest: /etc/nagios/nrpe.d/evolix.cfg
regexp: '^command\[check_redis\]=.+'
replace: 'command[check_redis]=sudo {{ redis_check_redis_path }} -H {{ redis_bind_interfaces | first }} -p {{ redis_port }}'
when: redis_instance_name is undefined
notify: restart nagios-nrpe-server
tags:
- redis
- nrpe
- name: sudo without password for nagios
ansible.builtin.lineinfile:
dest: /etc/sudoers.d/evolinux
regexp: 'check_redis$'
line: 'nagios ALL = NOPASSWD: {{ redis_check_redis_path }}'
insertafter: '^nagios'
validate: "visudo -cf %s"
when: redis_instance_name is undefined
tags:
- redis
- nrpe
- name: "Remount /usr with RW for 'install check_redis instance'"
ansible.builtin.include_role:
name: evolix/remount-usr
- name: install check_redis_instances
ansible.builtin.copy:
src: check_redis_instances.sh
dest: /usr/local/lib/nagios/plugins/check_redis_instances
force: true
mode: "0755"
owner: root
group: root
tags:
- redis
- nrpe
- name: Use check_redis_instances for NRPE
ansible.builtin.replace:
dest: /etc/nagios/nrpe.d/evolix.cfg
regexp: '^command\[check_redis\]=.+'
replace: 'command[check_redis]=sudo /usr/local/lib/nagios/plugins/check_redis_instances'
when: redis_instance_name is defined
notify: restart nagios-nrpe-server
tags:
- redis
- nrpe
- name: sudo without password for nagios
ansible.builtin.lineinfile:
dest: /etc/sudoers.d/evolinux
regexp: 'check_redis_instances$'
line: 'nagios ALL = NOPASSWD: /usr/local/lib/nagios/plugins/check_redis_instances'
insertafter: '^nagios'
validate: "visudo -cf %s"
when: redis_instance_name is defined
tags:
- redis
- nrpe