1
0
forked from infra/ansible

Add a very basic web role.

This commit is contained in:
Markus 2016-04-07 15:50:58 +02:00
parent ffdfa8f08b
commit 747feab2ad
6 changed files with 84 additions and 0 deletions

15
roles/web/files/certs Normal file
View File

@ -0,0 +1,15 @@
---
www.binary-kitchen.de:
- path: /etc/nginx/ssl/www.binary-kitchen.de.crt
user: root
group: root
perm: '400'
format: crt,ca
action: 'service nginx restart'
- path: /etc/nginx/ssl/www.binary-kitchen.de.key
user: root
group: root
perm: '400'
format: key
action: 'service nginx restart'

27
roles/web/files/vhost Normal file
View File

@ -0,0 +1,27 @@
server {
listen 80;
listen [::]:80;
server_name binary-kitchen.de www.binary-kitchen.de binary-kitchen.com www.binary-kitchen.com binary-kitchen.net www.binary-kitchen.net binary.kitchen www.binary.kitchen;
location /.well-known/acme-challenge/ {
default_type "text/plain";
root /var/www/acme-challenge/;
}
location / {
return 301 https://www.binary-kitchen.de$request_uri;
}
}
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name www.binary-kitchen.de;
ssl_certificate_key /etc/nginx/ssl/www.binary-kitchen.de.key;
ssl_certificate /etc/nginx/ssl/www.binary-kitchen.de.crt;
root /var/www/kitchen;
}

View File

@ -0,0 +1,7 @@
---
- name: Restart nginx
service: name=nginx state=restarted
- name: Restart php5-fpm
service: name=php5-fpm state=restarted

5
roles/web/meta/main.yml Normal file
View File

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

25
roles/web/tasks/main.yml Normal file
View File

@ -0,0 +1,25 @@
---
- name: Install php5-fpm
apt: name=php5-fpm state=present
- name: Create vhost directory
file: path=/var/www/kitchen state=directory owner=www-data group=www-data
- name: Ensure certificates are available
command: openssl req -x509 -nodes -newkey rsa:2048 -keyout /etc/nginx/ssl/www.binary-kitchen.de.key -out /etc/nginx/ssl/www.binary-kitchen.de.crt -days 730 -subj "/CN=www.binary-kitchen.de" creates=/etc/nginx/ssl/www.binary-kitchen.de.crt
notify: Restart nginx
- name: Configure certificate manager
copy: src=certs dest=/etc/acme/domains.d/www.binary-kitchen.de.conf
- name: Configure vhosts
copy: src=vhost 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
- name: Start php5-fpm
service: name=php5-fpm state=started enabled=yes

View File

@ -16,6 +16,11 @@
roles: roles:
- mail - mail
- name: Setup web server
hosts: beryllium.binary-kitchen.net
roles:
- web
- name: Setup jabber server - name: Setup jabber server
hosts: carbon.binary-kitchen.net hosts: carbon.binary-kitchen.net
roles: roles: