From 32e25e0e46b7ff8a9f79d75c947683a36bf57d9a Mon Sep 17 00:00:00 2001 From: Jeremy Lecour Date: Tue, 23 May 2017 15:11:33 +0200 Subject: [PATCH] nagios-nrpe: remount /usr if needed --- nagios-nrpe/tasks/debian.yml | 3 +++ nagios-nrpe/tasks/remount_usr_rw.yml | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 nagios-nrpe/tasks/remount_usr_rw.yml diff --git a/nagios-nrpe/tasks/debian.yml b/nagios-nrpe/tasks/debian.yml index f204f56f..6c245edc 100644 --- a/nagios-nrpe/tasks/debian.yml +++ b/nagios-nrpe/tasks/debian.yml @@ -25,6 +25,9 @@ state: directory notify: restart nagios-nrpe-server +- include: remount_usr_rw.yml + when: nagios_plugins_directory | search ("/usr") + - name: Nagios plugins are installed copy: src: plugins/ diff --git a/nagios-nrpe/tasks/remount_usr_rw.yml b/nagios-nrpe/tasks/remount_usr_rw.yml new file mode 100644 index 00000000..a62d86d6 --- /dev/null +++ b/nagios-nrpe/tasks/remount_usr_rw.yml @@ -0,0 +1,13 @@ +--- +- name: Get mount options for partitions + shell: "mount | grep 'on /usr type'" + args: + warn: no + register: mount + changed_when: False + failed_when: False + when: not ansible_check_mode + +- name: Remount /usr if it is a partition and it is not mounted in rw + command: "mount -o remount,rw /usr" + when: mount.rc == 0 and not mount.stdout_lines.0 | search("rw")