Add web-server for gateways
This commit is contained in:
parent
72357d34fa
commit
a0ef587a41
@ -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
|
||||
|
||||
|
7
roles/web-gw/handlers/main.yml
Normal file
7
roles/web-gw/handlers/main.yml
Normal file
@ -0,0 +1,7 @@
|
||||
---
|
||||
|
||||
- name: Restart nginx
|
||||
service: name=nginx state=restarted
|
||||
|
||||
- name: Run certmgr
|
||||
command: /opt/acertmgr/acertmgr.py
|
5
roles/web-gw/meta/main.yml
Normal file
5
roles/web-gw/meta/main.yml
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
|
||||
dependencies:
|
||||
- { role: certmgr }
|
||||
- { role: nginx, nginx_ssl: True }
|
17
roles/web-gw/tasks/main.yml
Normal file
17
roles/web-gw/tasks/main.yml
Normal 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
|
15
roles/web-gw/templates/certs.j2
Normal file
15
roles/web-gw/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'
|
25
roles/web-gw/templates/vhost.j2
Normal file
25
roles/web-gw/templates/vhost.j2
Normal 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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user