mastible/roles/mastodon-nginx/tasks/main.yml

30 lines
1.0 KiB
YAML
Raw Normal View History

2017-11-26 23:03:27 +00:00
---
# This role install nginx, configures it and sets up a Let's Encrypt certificate for the
# Mastodon instance
- name: Install nginx and letsencrypt
apt: name={{ item }} state=latest update_cache=yes
with_items:
- nginx
- letsencrypt
- name: Stop nginx for now
service: name=nginx state=stopped
- name: Generate Let's Encrypt TLS certificate for Mastodon instance
2017-11-26 23:08:20 +00:00
shell: letsencrypt certonly -n --agree-tos --standalone -d {{ mastodon_hostname }} --email "webmaster@{{ mastodon_hostname }}"
2017-11-26 23:03:27 +00:00
- name: Remove default nginx config in sites-enabled
file:
path: /etc/nginx/sites-enabled/default
state: absent
- name: Copy Mastodon nginx vhost template to sites-available
copy:
src: mastodon-nginx.conf
dest: /etc/nginx/sites-available/{{ mastodon_hostname }}.conf
backup: yes
- name: Enable Mastodon nginx vhost template
file:
src: /etc/nginx/sites-available/{{ mastodon_hostname }}.conf
dest: /etc/nginx/sites-enabled/{{ mastodon_hostname }}.conf
state: link
- name: Start nginx
service: name=nginx state=started