--- - name: Install nginx hosts: teier.eu gather_facts: yes tasks: - name: Upgrade system apt: upgrade=dist update_cache=yes - name: Install nginx apt: name=nginx state=latest - name: Install certbot apt: name=certbot state=latest - name: Stop Nginx for configuration and certificate approval service: name=nginx state=stopped - name: Remove nginx site config shell: "rm -f /etc/nginx/sites-enabled/*" - name: Get Certificate shell: certbot certonly --standalone --preferred-challenges http -m mathias.teier@icloud.com --agree-tos -n -d teier.eu -d cloud.teier.eu -d nummus.teier.eu -d www.teier.eu -d collabora.teier.eu -d matrix.teier.eu -d kagent.at -d www.kagent.at -d git.kagent.at - name: Install nginx server config copy: src: nginx.conf dest: /etc/nginx/nginx.conf - name: Install nginx site configs copy: src: sites/ dest: /etc/nginx/sites-enabled/ - name: Start nginx service: name=nginx state=started - name: Add letsencrypt cronjob for cert renewal cron: name: renew_cert day: "1,15" hour: "2" job: service nginx stop && certbot --renew && service nginx start