forked from FF-RGB/ansible
Add NGINX Role tailored for stateserver usage
This commit is contained in:
parent
d909edc169
commit
309105d948
@ -19,6 +19,8 @@ yanic_database_delete_after: 720d
|
||||
|
||||
yanic_dbc_repondd_enable: false
|
||||
|
||||
nginx_ssl: true
|
||||
|
||||
yanic_influxdb:
|
||||
- enable: true
|
||||
host: http://127.0.0.1:8086
|
||||
|
7
roles/web_stats/handlers/main.yml
Normal file
7
roles/web_stats/handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Restart nginx
|
||||
service: name=nginx state=restarted
|
||||
|
||||
- name: Run acertmgr
|
||||
command: /usr/bin/acertmgr
|
5
roles/web_stats/meta/main.yml
Normal file
5
roles/web_stats/meta/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
dependencies:
|
||||
- { role: acertmgr }
|
||||
- { role: nginx, nginx_ssl: True }
|
26
roles/web_stats/tasks/main.yml
Normal file
26
roles/web_stats/tasks/main.yml
Normal file
@ -0,0 +1,26 @@
|
||||
---
|
||||
|
||||
- name: Ensure certificates are available
|
||||
command:
|
||||
cmd: >
|
||||
openssl req -x509 -nodes -newkey rsa:2048
|
||||
-keyout /etc/nginx/ssl/{{ ansible_fqdn }}.key
|
||||
-out /etc/nginx/ssl/{{ ansible_fqdn }}.crt
|
||||
-days 730 -subj "/CN={{ ansible_fqdn }}"
|
||||
creates: /etc/nginx/ssl/{{ ansible_fqdn }}.crt
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Create web content directory
|
||||
file: path=/var/www/html state=directory mode=0755
|
||||
|
||||
- name: Configure certificate manager
|
||||
template: src=certs.j2 dest=/etc/acertmgr/{{ ansible_fqdn }}.conf
|
||||
notify: Run acertmgr
|
||||
|
||||
- name: Configure vhosts
|
||||
template: src=vhost.j2 dest=/etc/nginx/sites-available/www
|
||||
notify: Restart nginx
|
||||
|
||||
- name: Enable vhosts
|
||||
file: src=/etc/nginx/sites-available/www dest=/etc/nginx/sites-enabled/www state=link
|
||||
notify: Restart nginx
|
15
roles/web_stats/templates/certs.j2
Normal file
15
roles/web_stats/templates/certs.j2
Normal file
@ -0,0 +1,15 @@
|
||||
---
|
||||
|
||||
{{ ansible_fqdn }}:
|
||||
- path: /etc/nginx/ssl/{{ ansible_fqdn }}.crt
|
||||
user: root
|
||||
group: root
|
||||
perm: '400'
|
||||
format: crt,ca
|
||||
action: '/usr/sbin/service nginx restart'
|
||||
- path: /etc/nginx/ssl/{{ ansible_fqdn }}.key
|
||||
user: root
|
||||
group: root
|
||||
perm: '400'
|
||||
format: key
|
||||
action: '/usr/sbin/service nginx restart'
|
36
roles/web_stats/templates/vhost.j2
Normal file
36
roles/web_stats/templates/vhost.j2
Normal file
@ -0,0 +1,36 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
|
||||
server_name _;
|
||||
|
||||
location /.well-known/acme-challenge {
|
||||
default_type "text/plain";
|
||||
alias /var/www/acme-challenge;
|
||||
}
|
||||
root /var/www/html;
|
||||
|
||||
}
|
||||
|
||||
server {
|
||||
listen 443 ssl http2;
|
||||
listen [::]:443 ssl http2;
|
||||
|
||||
proxy_set_header X-Forwarded-For $remote_addr;
|
||||
|
||||
server_name {{ ansible_fqdn }};
|
||||
|
||||
ssl_certificate_key /etc/nginx/ssl/{{ ansible_fqdn }}.key;
|
||||
ssl_certificate /etc/nginx/ssl/{{ ansible_fqdn }}.crt;
|
||||
|
||||
root /var/www/html;
|
||||
|
||||
location / {
|
||||
proxy_pass http://localhost:3000/
|
||||
}
|
||||
location /meshviewer {
|
||||
alias /var/www/html/meshviewer;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user