Add web-server for gateways

This commit is contained in:
Markus 2017-07-03 21:18:45 +02:00
parent 72357d34fa
commit a0ef587a41
7 changed files with 73 additions and 0 deletions

View File

@ -32,6 +32,9 @@
- /etc/acme/account.key
- /etc/acme/server.key
- name: Download Lets Encrypt CA certificate
get_url: url=https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem dest=/etc/acme/lets-encrypt-x3-cross-signed.pem
- name: Create challenge directory
file: path=/var/www/acme-challenge/ owner=root mode=0755 state=directory

View File

@ -0,0 +1,7 @@
---
- name: Restart nginx
service: name=nginx state=restarted
- name: Run certmgr
command: /opt/acertmgr/acertmgr.py

View File

@ -0,0 +1,5 @@
---
dependencies:
- { role: certmgr }
- { role: nginx, nginx_ssl: True }

View File

@ -0,0 +1,17 @@
---
- name: Ensure certificates are available
command: 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: Configure certificate manager
template: src=certs.j2 dest=/etc/acme/domains.d/{{ ansible_fqdn }}.conf
notify: Run certmgr
- 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

View 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'

View File

@ -0,0 +1,25 @@
server {
listen 80;
listen [::]:80;
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;
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;
}

View File

@ -18,6 +18,7 @@
- dhcpd
- respondd
- yanic
- web-gw
- name: Setup confluence server
hosts: confluence.regensburg.freifunk.net