From 8703443268ed8fa2d36598ac1b5cb236b6113c25 Mon Sep 17 00:00:00 2001 From: Geno Date: Sun, 11 Oct 2020 12:06:32 +0200 Subject: [PATCH] mxdomain website --- tasks/main.yml | 5 +++++ tasks/website.yml | 23 +++++++++++++++++++++++ templates/mxdomain-website-domain.nginx | 14 ++++++++++++++ templates/mxdomain-website.html | 3 +++ 4 files changed, 45 insertions(+) create mode 100644 tasks/website.yml create mode 100644 templates/mxdomain-website-domain.nginx create mode 100644 templates/mxdomain-website.html diff --git a/tasks/main.yml b/tasks/main.yml index 06bdbec..dca830a 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -61,3 +61,8 @@ import_tasks: roundcubemail.yml tags: roundcubemail +- name: Run MX-Domain Website + when: mailserver_website != "" + import_tasks: website.yml + tags: website + diff --git a/tasks/website.yml b/tasks/website.yml new file mode 100644 index 0000000..dfcb4a2 --- /dev/null +++ b/tasks/website.yml @@ -0,0 +1,23 @@ +- name: website - get cert for nginx domain + notify: dehydrated + when: mailserver_mx_domain != "" + lineinfile: + path: /etc/dehydrated/domains.txt + line: "{{ mailserver_mx_domain }}" + +- name: website - nginx domain + notify: reload nginx + when: mailserver_mx_domain != "" + template: + src: mxdomain-website-domain.nginx + dest: /etc/nginx/sites.d/mxdomain.act + +- name: website - directory + file: + state: directory + path: "/srv/http/{{ mailserver_mx_domain }}" + +- name: website - index.html + template: + src: mxdomain-website.html + dest: "/srv/http/{{ mailserver_mx_domain }}/index.html" diff --git a/templates/mxdomain-website-domain.nginx b/templates/mxdomain-website-domain.nginx new file mode 100644 index 0000000..bbfebc8 --- /dev/null +++ b/templates/mxdomain-website-domain.nginx @@ -0,0 +1,14 @@ +server { + listen [::]:443 ssl http2; + listen 443 ssl http2; + + server_name {{ mailserver_mx_domain }}; + + ssl_certificate /etc/dehydrated/certs/{{ mailserver_mx_domain }}/fullchain.pem; + ssl_certificate_key /etc/dehydrated/certs/{{ mailserver_mx_domain }}/privkey.pem; + + include snippets/letsencrypt.conf; + + root /srv/http/{{ mailserver_mx_domain }}; + index index.html index.htm index.php; +} diff --git a/templates/mxdomain-website.html b/templates/mxdomain-website.html new file mode 100644 index 0000000..318cc88 --- /dev/null +++ b/templates/mxdomain-website.html @@ -0,0 +1,3 @@ +

Mailserver: {{mailserver_mx_domain}}

+This is a Mailserver from +{{mailserver_website}}