Browse Source

web_mc: webserver for minecraft map

master
Markus 2 months ago
parent
commit
39e5ad9e20
7 changed files with 81 additions and 0 deletions
  1. +2
    -0
      group_vars/all/vars.yml
  2. +7
    -0
      roles/web_mc/handlers/main.yml
  3. +5
    -0
      roles/web_mc/meta/main.yml
  4. +20
    -0
      roles/web_mc/tasks/main.yml
  5. +15
    -0
      roles/web_mc/templates/certs.j2
  6. +27
    -0
      roles/web_mc/templates/vhost.j2
  7. +5
    -0
      site.yml

+ 2
- 0
group_vars/all/vars.yml View File

@ -100,6 +100,8 @@ matrix_dbname: matrix
matrix_dbuser: matrix
matrix_dbpass: "{{ vault_matrix_dbpass }}"
mc_domain: minecraft.binary-kitchen.de
nextcloud_domain: oc.binary-kitchen.de
nextcloud_dbname: owncloud
nextcloud_dbuser: owncloud


+ 7
- 0
roles/web_mc/handlers/main.yml View File

@ -0,0 +1,7 @@
---
- name: Restart nginx
service: name=nginx state=restarted
- name: Run acertmgr
command: /usr/bin/acertmgr

+ 5
- 0
roles/web_mc/meta/main.yml View File

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

+ 20
- 0
roles/web_mc/tasks/main.yml View File

@ -0,0 +1,20 @@
---
- name: Create vhost directory
file: path=/var/www/mc 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/{{ mc_domain }}.key -out /etc/nginx/ssl/{{ mc_domain }}.crt -days 730 -subj "/CN={{ mc_domain }}" creates=/etc/nginx/ssl/{{ mc_domain }}.crt
notify: Restart nginx
- name: Configure certificate manager
template: src=certs.j2 dest=/etc/acertmgr/{{ mc_domain }}.conf
notify: Run acertmgr
- name: Configure vhosts
template: src=vhost.j2 dest=/etc/nginx/sites-available/mc
notify: Restart nginx
- name: Enable vhosts
file: src=/etc/nginx/sites-available/mc dest=/etc/nginx/sites-enabled/mc state=link
notify: Restart nginx

+ 15
- 0
roles/web_mc/templates/certs.j2 View File

@ -0,0 +1,15 @@
---
{{ mc_domain }}:
- path: /etc/nginx/ssl/{{ mc_domain }}.key
user: root
group: root
perm: '400'
format: key
action: '/usr/sbin/service nginx restart'
- path: /etc/nginx/ssl/{{ mc_domain }}.crt
user: root
group: root
perm: '400'
format: crt,ca
action: '/usr/sbin/service nginx restart'

+ 27
- 0
roles/web_mc/templates/vhost.j2 View File

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

+ 5
- 0
site.yml View File

@ -104,3 +104,8 @@
hosts: technetium.binary-kitchen.net
roles:
- web_plk
- name: Setup minecraft server
hosts: ruthenium.binary-kitchen.net
roles:
- web_mc

Loading…
Cancel
Save