From 059f38debd96f5f62de8fac56f041df91a932015 Mon Sep 17 00:00:00 2001 From: Danny Date: Fri, 21 Nov 2025 19:48:04 +0100 Subject: [PATCH] added psutil --- roles/pips/tasks/nagios_tasks.yml | 40 +++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/roles/pips/tasks/nagios_tasks.yml b/roles/pips/tasks/nagios_tasks.yml index aa4fded..04de141 100644 --- a/roles/pips/tasks/nagios_tasks.yml +++ b/roles/pips/tasks/nagios_tasks.yml @@ -48,6 +48,46 @@ when: - ansible_facts['os_family'] == 'FreeBSD' - not nrpe_installed + +- name: Set psutil_installed fact if any package name contains "psutil" + ansible.builtin.set_fact: + psutil_installed: "{{ (ansible_facts.packages | default({}) | dict2items | map(attribute='key') | select('search','psutil') | list) | length > 0 }}" + +- name: Debug psutil presence + ansible.builtin.debug: + msg: "psutil already installed on host." + when: psutil_installed + +- name: Ensure python3-psutil is installed (Debian/Ubuntu) + ansible.builtin.apt: + name: python3-psutil + state: present + become: yes + register: psutil_install_result + when: + - ansible_facts['os_family'] == 'Debian' + - not psutil_installed + +- name: Ensure python3-psutil is installed (RedHat/CentOS) + ansible.builtin.yum: + name: python3-psutil + state: present + become: yes + register: psutil_install_result + when: + - ansible_facts['os_family'] == 'RedHat' + - not psutil_installed + +- name: Ensure psutil is installed (FreeBSD) + ansible.builtin.pkg: + name: python3-psutil + state: present + become: yes + register: psutil_install_result + when: + - ansible_facts['os_family'] == 'FreeBSD' + - not psutil_installed + - name: Deploy custom Nagios/NRPE script ansible.builtin.copy: