Add nginx-light role for hypervisors and backups servers
This commit is contained in:
parent
83c8faab2d
commit
a949637e5a
9
nginx-light/README.md
Normal file
9
nginx-light/README.md
Normal file
|
@ -0,0 +1,9 @@
|
|||
# nginx-light
|
||||
|
||||
Install Nginx light with a simply default vhost config.
|
||||
|
||||
Used for hypervisors and backups servers.
|
||||
|
||||
## Tasks
|
||||
|
||||
Everything is in the `tasks/main.yml` file.
|
5
nginx-light/handlers/main.yml
Normal file
5
nginx-light/handlers/main.yml
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
- name: reload nginx
|
||||
service:
|
||||
name: nginx
|
||||
state: reloaded
|
35
nginx-light/tasks/main.yml
Normal file
35
nginx-light/tasks/main.yml
Normal file
|
@ -0,0 +1,35 @@
|
|||
---
|
||||
- name: Ensure Nginx (light) is installed
|
||||
apt:
|
||||
name: nginx-light
|
||||
state: present
|
||||
notify: reload nginx
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
|
||||
- name: Copy default vhost
|
||||
template:
|
||||
src: default.j2
|
||||
dest: /etc/nginx/sites-available/default
|
||||
mode: 0644
|
||||
notify: reload nginx
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
|
||||
- name: Enable default vhost
|
||||
file:
|
||||
src: /etc/nginx/sites-available/default
|
||||
dest: /etc/nginx/sites-enabled/default
|
||||
state: link
|
||||
notify: reload nginx
|
||||
tags:
|
||||
- nginx
|
||||
- packages
|
||||
|
||||
- name: Ensure Nginx is enabled
|
||||
service:
|
||||
name: nginx
|
||||
state: started
|
||||
enabled: yes
|
31
nginx-light/templates/default.j2
Normal file
31
nginx-light/templates/default.j2
Normal file
|
@ -0,0 +1,31 @@
|
|||
server {
|
||||
listen 80 default_server;
|
||||
listen [::]:80 default_server;
|
||||
|
||||
listen 443 ssl default_server;
|
||||
listen [::]:443 ssl default_server;
|
||||
|
||||
if ($host != "{{ ansible_fqdn }}") {
|
||||
rewrite ^ https://{{ ansible_fqdn }}$request_uri permanent;
|
||||
}
|
||||
|
||||
include snippets/snakeoil.conf;
|
||||
|
||||
if ($https != "on") {
|
||||
return 301 https://{{ ansible_fqdn }}$request_uri;
|
||||
}
|
||||
|
||||
root /var/www/;
|
||||
|
||||
location /munin {
|
||||
alias /var/cache/munin/www;
|
||||
}
|
||||
|
||||
index index.html;
|
||||
|
||||
server_name _;
|
||||
|
||||
location / {
|
||||
try_files $uri $uri/ =404;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue