ansible/roles/nrpe/tasks/main.yml

69 lines
1.7 KiB
YAML

---
- name: Gather OS specific variables for nrpe
include_vars: "{{ item }}"
with_first_found:
- "{{ ansible_distribution|lower }}-{{ ansible_distribution_major_version }}.yml"
- "{{ ansible_distribution|lower }}.yml"
- "{{ ansible_os_family|lower }}.yml"
- "main.yml"
- name: Enable CentOS-PowerTools repository
block:
- name: Enable CentOS-PowerTools repository
yum_repository:
name: PowerTools
file: CentOS-PowerTools
description: CentOS-$releasever - PowerTool
mirrorlist: http://mirrorlist.centos.org/?release=$releasever&arch=$basearch&repo=PowerTools&infra=$infra
enabled: yes
gpgcheck: 1
gpgkey: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
when: (ansible_facts['distribution'] == 'CentOS' and ansible_facts['distribution_major_version'] == "8")
- name: Enable CentOS-EPEL repository
block:
- name: Enable CentOS-EPEL repository
package:
name: epel-release
state: present
- name: Update yum cache (on Redhat).
yum:
update_cache: true
when: (ansible_facts['distribution'] == 'CentOS')
- name: Install NRPE service
package:
name: "{{ nrpe_package }}"
state: present
tags:
- packages
- name: Install NRPE plugins
package:
name: "{{ nrpe_plugin_packages }}"
state: present
tags:
- packages
- name: Create nrpe.cfg from template
template:
src: "nrpe_local.cfg.j2"
dest: "{{ nrpe_server_dir }}/nrpe_local.cfg"
owner: root
group: nagios
mode: "0640"
notify: restart nrpe service
tags:
- configuration
- name: Ensure NRPE server is running
service:
name: "{{ nrpe_service }}"
state: started
enabled: true