diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..016a506 --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +files/maintenance.jpg filter=lfs diff=lfs merge=lfs -text diff --git a/files/maintenance.html b/files/maintenance.html new file mode 100644 index 0000000..405798a --- /dev/null +++ b/files/maintenance.html @@ -0,0 +1,37 @@ + + + + + + + + Server maintenance + + + + +

+ Serval Server maintenance +

+ +

+ The server is probably under maintenance by the serval cat. +

+ + The serval cat is sitting on the keyboard + + diff --git a/files/maintenance.jpg b/files/maintenance.jpg new file mode 100644 index 0000000..53c51f4 --- /dev/null +++ b/files/maintenance.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06daab60034dffbd539bdf87c88bb21a8a00b8da86e6d39541b4f93623e6ba4e +size 37295 diff --git a/tasks/install.yml b/tasks/install.yml index 0bef25f..11c4f4c 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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 diff --git a/tasks/purge.yml b/tasks/purge.yml index 09696e7..eec6a8c 100644 --- a/tasks/purge.yml +++ b/tasks/purge.yml @@ -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' diff --git a/templates/maintenance.conf b/templates/maintenance.conf new file mode 100644 index 0000000..d23f196 --- /dev/null +++ b/templates/maintenance.conf @@ -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 }}; } diff --git a/vars/main.yml b/vars/main.yml index 5a6f88b..2dc0107 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -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'