From be84ab434eff154d48ce1df8f7f05074664a2a46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Lecour?= Date: Sat, 7 Oct 2017 11:55:02 +0200 Subject: [PATCH] apache: install save_apache_status.sh --- apache/files/save_apache_status.sh | 18 ++++++++++++++++++ apache/tasks/main.yml | 9 +++++++++ apache/tasks/remount_usr_rw.yml | 15 +++++++++++++++ 3 files changed, 42 insertions(+) create mode 100644 apache/files/save_apache_status.sh create mode 100644 apache/tasks/remount_usr_rw.yml diff --git a/apache/files/save_apache_status.sh b/apache/files/save_apache_status.sh new file mode 100644 index 00000000..d65b2e08 --- /dev/null +++ b/apache/files/save_apache_status.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +set -e + +DIR="/var/log/apache-status" +URL="http://127.0.0.1/server-status" +TS=`date +%Y%m%d%H%M%S` +FILE="${DIR}/${TS}.html" + +mkdir -p "${DIR}" + +wget -q -O "${FILE}" "${URL}" + +chmod 640 "${FILE}" + +find "${DIR}" -type f -mtime +1 -delete + +exit 0 diff --git a/apache/tasks/main.yml b/apache/tasks/main.yml index ee6d3b47..ed99fe5a 100644 --- a/apache/tasks/main.yml +++ b/apache/tasks/main.yml @@ -127,6 +127,15 @@ tags: - apache +- include: remount_usr_rw.yml + +- name: "Install save_apache_status.sh" + copy: + src: save_apache_status.sh + dest: /usr/share/scripts/save_apache_status.sh + mode: "0755" + force: no + - include: log2mail.yml when: apache_log2mail_include diff --git a/apache/tasks/remount_usr_rw.yml b/apache/tasks/remount_usr_rw.yml new file mode 100644 index 00000000..8c51aee2 --- /dev/null +++ b/apache/tasks/remount_usr_rw.yml @@ -0,0 +1,15 @@ +--- +- 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") + args: + warn: no