From d4ff53ff4b03811bc97d38d769b718116f73de22 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Tue, 12 Jul 2016 15:09:40 -0400 Subject: [PATCH] common: Enable nrpe installation without epel repo on RHEL/CentOS Signed-off-by: David Galloway --- roles/common/tasks/nagios.yml | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/roles/common/tasks/nagios.yml b/roles/common/tasks/nagios.yml index 7d83766..76f5ad5 100644 --- a/roles/common/tasks/nagios.yml +++ b/roles/common/tasks/nagios.yml @@ -7,6 +7,26 @@ include_vars: yum_systems.yml when: ansible_pkg_mgr == "yum" +# Returns 0 if found and 1 if not found +# Task fails if not found. Hence ignore_errors: true +- name: Check for epel + shell: "grep -q 'epel' /etc/yum.repos.d/*" + register: have_epel + no_log: true + ignore_errors: true + when: ansible_pkg_mgr == "yum" + +# This task is only run when epel isn't present +- name: Install nrpe without epel + yum: + name: "{{ item }}" + state: present + with_items: + - http://{{ mirror_host }}/lab-extras/rhel7/x86_64/nagios-common-4.0.8-2.el7.x86_64.rpm + - http://{{ mirror_host }}/lab-extras/rhel7/x86_64/nrpe-2.15-7.el7.x86_64.rpm + when: ansible_pkg_mgr == "yum" and + have_epel.rc == 1 + - name: Install nrpe package and dependencies (RHEL/CentOS) yum: name: "{{ item }}" @@ -15,7 +35,8 @@ with_items: - nrpe - smartmontools - when: ansible_pkg_mgr == "yum" + when: ansible_pkg_mgr == "yum" and + have_epel.rc == 0 - name: Install nrpe package and dependencies (Ubuntu) apt: -- 2.39.5