2018-01-02 19:41:32 +01:00
|
|
|
---
|
|
|
|
|
2018-01-18 17:17:34 +01:00
|
|
|
- name: server status dirname exists
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.file:
|
2018-01-18 17:17:34 +01:00
|
|
|
dest: "{{ apache_serverstatus_suffix_file | dirname }}"
|
|
|
|
mode: "0700"
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
state: directory
|
|
|
|
|
2018-01-02 19:41:32 +01:00
|
|
|
- name: set apache serverstatus suffix if provided
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.copy:
|
2018-09-09 23:01:43 +02:00
|
|
|
dest: "{{ apache_serverstatus_suffix_file }}"
|
|
|
|
# The last character "\u000A" is a line feed (LF), it's better to keep it
|
|
|
|
content: "{{ apache_serverstatus_suffix }}\u000A"
|
2023-06-28 13:22:59 +02:00
|
|
|
force: true
|
2021-05-09 23:06:42 +02:00
|
|
|
when: apache_serverstatus_suffix | length > 0
|
2018-01-02 19:41:32 +01:00
|
|
|
|
|
|
|
- name: generate random string for server-status suffix
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.shell:
|
|
|
|
cmd: "apg -a 1 -M N -n 1 > {{ apache_serverstatus_suffix_file }}"
|
2018-01-02 19:41:32 +01:00
|
|
|
args:
|
|
|
|
creates: "{{ apache_serverstatus_suffix_file }}"
|
|
|
|
|
|
|
|
- name: read apache server status suffix
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.command:
|
|
|
|
cmd: "tail -n 1 {{ apache_serverstatus_suffix_file }}"
|
2018-01-02 19:41:32 +01:00
|
|
|
changed_when: False
|
|
|
|
check_mode: no
|
|
|
|
register: new_apache_serverstatus_suffix
|
|
|
|
|
|
|
|
- name: overwrite apache_serverstatus_suffix
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.set_fact:
|
2018-01-02 19:41:32 +01:00
|
|
|
apache_serverstatus_suffix: "{{ new_apache_serverstatus_suffix.stdout }}"
|
|
|
|
|
2023-03-20 23:33:19 +01:00
|
|
|
- ansible.builtin.debug:
|
2018-01-02 19:41:32 +01:00
|
|
|
var: apache_serverstatus_suffix
|
2021-05-01 22:11:08 +02:00
|
|
|
verbosity: 1
|
2018-01-02 19:41:32 +01:00
|
|
|
|
|
|
|
- name: replace server-status suffix in default site index
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.replace:
|
2018-01-02 19:41:32 +01:00
|
|
|
dest: /var/www/index.html
|
|
|
|
regexp: '__SERVERSTATUS_SUFFIX__'
|
|
|
|
replace: "{{ apache_serverstatus_suffix }}"
|
2019-01-01 21:08:51 +01:00
|
|
|
|
2019-04-26 11:02:02 +02:00
|
|
|
- name: add server-status suffix in default site index if missing
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.replace:
|
2019-04-26 11:02:02 +02:00
|
|
|
dest: /var/www/index.html
|
2019-05-02 12:16:36 +02:00
|
|
|
regexp: '"/server-status-?"'
|
2019-04-26 11:02:02 +02:00
|
|
|
replace: '"/server-status-{{ apache_serverstatus_suffix }}"'
|
|
|
|
|
2019-04-25 17:12:13 +02:00
|
|
|
- name: add server-status suffix in default VHost
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.replace:
|
2019-04-25 17:12:13 +02:00
|
|
|
dest: /etc/apache2/sites-available/000-evolinux-default.conf
|
2019-05-02 12:16:36 +02:00
|
|
|
regexp: '<Location /server-status-?>'
|
2019-04-25 17:12:13 +02:00
|
|
|
replace: '<Location /server-status-{{ apache_serverstatus_suffix }}>'
|
|
|
|
notify: reload apache
|
|
|
|
|
2019-01-01 21:08:51 +01:00
|
|
|
- name: Munin configuration has a section for apache
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2019-01-01 21:08:51 +01:00
|
|
|
dest: /etc/munin/plugin-conf.d/munin-node
|
|
|
|
line: "[apache_*]"
|
|
|
|
create: no
|
|
|
|
|
|
|
|
- name: apache-status URL is configured for Munin
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2019-01-01 21:08:51 +01:00
|
|
|
dest: /etc/munin/plugin-conf.d/munin-node
|
2019-06-20 17:29:23 +02:00
|
|
|
line: "env.url http://{{ apache_serverstatus_host }}/server-status-{{ apache_serverstatus_suffix }}?auto"
|
|
|
|
regexp: 'env.url http://[^\\/]+/server-status'
|
2019-01-01 21:08:51 +01:00
|
|
|
insertafter: "[apache_*]"
|
|
|
|
create: no
|
2019-06-20 17:29:23 +02:00
|
|
|
notify: restart munin-node
|
2023-02-24 15:41:39 +01:00
|
|
|
|
|
|
|
- name: add mailgraph URL in index.html
|
2023-03-20 23:33:19 +01:00
|
|
|
ansible.builtin.lineinfile:
|
2023-02-24 15:41:39 +01:00
|
|
|
dest: /var/www/index.html
|
|
|
|
state: present
|
|
|
|
line: ' <li><a href="/mailgraph">Stats Mail</a></li>'
|
|
|
|
insertbefore: "</ul>"
|