Add maintenance snippet

This commit is contained in:
Alex Kotov 2023-05-29 17:14:15 +04:00
parent d464f7100c
commit 24fb092cc1
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
7 changed files with 89 additions and 1 deletions

1
.gitattributes vendored Normal file
View file

@ -0,0 +1 @@
files/maintenance.jpg filter=lfs diff=lfs merge=lfs -text

37
files/maintenance.html Normal file
View file

@ -0,0 +1,37 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<meta name="viewport" content="width=device-width,
initial-scale=1,
maximum-scale=1,
shrink-to-fit=no,
user-scalable=no"/>
<title>Server maintenance</title>
<style>
.center-text { text-align: center; }
.center {
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<h1 class="center-text">
<s>Serval</s> Server maintenance
</h1>
<p class="center-text">
The server is probably under maintenance by the serval cat.
</p>
<img
src="maintenance.jpg"
class="center"
alt="The serval cat is sitting on the keyboard"/>
</body>
</html>

3
files/maintenance.jpg Normal file
View file

@ -0,0 +1,3 @@
version https://git-lfs.github.com/spec/v1
oid sha256:06daab60034dffbd539bdf87c88bb21a8a00b8da86e6d39541b4f93623e6ba4e
size 37295

View file

@ -18,6 +18,18 @@
- '{{ nginx__enabled_dir }}'
- '{{ nginx__snippets_dir }}'
- name: Create directories for Nginx HTML files
notify: nginx | Restart Nginx
file:
state: directory
path: '{{ item }}'
mode: 'u=rwx,go=rx'
owner: root
group: root
with_items:
- '{{ nginx__dir_www }}'
- '{{ nginx__dir_www_html }}'
- name: Install Nginx config
notify: nginx | Restart Nginx
copy:
@ -72,3 +84,24 @@
owner: root
group: root
with_items: '{{ nginx__sites }}'
- name: Install maintenance files
notify: nginx | Restart Nginx
copy:
src: 'files/{{ item }}'
dest: '{{ nginx__dir_www_html }}/{{ item }}'
mode: 'u=rw,go=r'
owner: root
group: root
with_items:
- 'maintenance.html'
- 'maintenance.jpg'
- name: Install maintenance snippet
notify: nginx | Restart Nginx
template:
src: 'templates/maintenance.conf'
dest: '{{ nginx__snippets_dir }}/maintenance.conf'
mode: 'u=rw,go=r'
owner: root
group: root

View file

@ -12,3 +12,11 @@
file:
state: absent
path: '{{ nginx__dir_etc }}'
- name: Delete maintenance files
file:
state: absent
path: '{{ nginx__dir_www_html }}/{{ item }}'
with_items:
- 'maintenance.html'
- 'maintenance.jpg'

View file

@ -0,0 +1,4 @@
error_page 502 = /maintenance.html;
location = /maintenance.html { root {{ nginx__dir_www_html }}; }
location = /maintenance.jpg { root {{ nginx__dir_www_html }}; }

View file

@ -1,7 +1,9 @@
---
nginx__dir_etc: '/etc/nginx'
nginx__confd_dir: '{{ nginx__dir_etc }}/conf.d'
nginx__available_dir: '{{ nginx__dir_etc }}/sites-available'
nginx__enabled_dir: '{{ nginx__dir_etc }}/sites-enabled'
nginx__snippets_dir: '{{ nginx__dir_etc }}/snippets'
nginx__dir_www: '/var/www'
nginx__dir_www_html: '{{ nginx__dir_www }}/html'