nginx: Aktualisiere Rolle. Dient nun zur allgemeinen Einrichtung von Nginx

This commit is contained in:
phil 2022-06-19 20:30:17 +02:00
commit c9ed568d78
8 changed files with 92 additions and 0 deletions

4
README.md Normal file
View file

@ -0,0 +1,4 @@
Nginx
=====
Diese Rolle dient zur grundlegenden Einrichtung von Nginx.

14
handlers/main.yaml Normal file
View file

@ -0,0 +1,14 @@
- name: restart munin-node
service:
name: munin-node
state: restarted
- name: reload nginx
service:
name: nginx
state: reloaded
- name: reload monit
service:
name: monit
state: reloaded

10
meta/main.yml Normal file
View file

@ -0,0 +1,10 @@
galaxy_info:
author: systemausfall.org
description: Ersteinrichtung von Nginx
company: Sense.Lab e.V.
license: GPLv3
min_ansible_version: 2.9
platforms:
- name: Debian
version:
- Bullseye

6
tasks/main.yaml Normal file
View file

@ -0,0 +1,6 @@
---
- import_tasks: packages.yml
tags: packages
- import_tasks: monitoring.yml
tags: monitoring

29
tasks/monitoring.yml Normal file
View file

@ -0,0 +1,29 @@
---
- name: "monitoring | Aktiviere Munin-Plugin"
file:
src: "/usr/share/munin/plugins/nginx_{{ item }}"
dest: "/etc/munin/plugins/nginx_{{ item }}"
state: link
loop:
- request
- status
notify: restart munin-node
- name: "monitoring | Kopiere Datei für lokale Statusausgabe"
template:
src: local-statistics.j2
dest: /etc/nginx/sites-available/local-statistics
notify: reload nginx
- name: "monitoring | Aktiviere Lokale Status-Ausgabe"
file:
src: /etc/nginx/sites-available/local-statistics
dest: /etc/nginx/sites-enabled/local-statistics
state: link
notify: reload nginx
- name: "monitoring | Kopiere Monit-Überwachung"
template:
src: monit.j2
dest: /etc/monit/conf-enabled/nginx
notify: reload monit

6
tasks/packages.yml Normal file
View file

@ -0,0 +1,6 @@
---
- name: "packages | Installiere Debian-Pakete"
apt:
pkg:
- liblwp-useragent-determined-perl
- nginx-full

View file

@ -0,0 +1,15 @@
server {
{% if inventory_hostname == "sl-nextcloud.kahlo" %}
listen 127.0.0.1:81;
{% else %}
listen 127.0.0.1;
{% endif %}
server_name localhost;
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.0/8;
allow ::1/128;
deny all;
}
}

8
templates/monit.j2 Normal file
View file

@ -0,0 +1,8 @@
# {{ ansible_managed }}
check process nginx with pidfile /var/run/nginx.pid
group webserver
start program = "/usr/sbin/service nginx start"
stop program = "/usr/sbin/service nginx stop"
if failed host 127.0.0.1 port {{ nginx_port |default(80) }} for 3 cycles then restart
if 5 restarts with 5 cycles then timeout