main.yml 669 B

123456789101112131415161718192021222324
  1. - name: Remove file nginx default host
  2. become: true
  3. ansible.builtin.file:
  4. path: /etc/nginx/sites-enabled/default
  5. state: absent
  6. - name: add Let's Encrypt support
  7. become: true
  8. ansible.builtin.shell:
  9. cmd: certbot --nginx --non-interactive --agree-tos -m {{ app_master_email }} --domains {{ inventory_hostname }} "{{ '--redirect' if app_nginx_force_https else '' }}"
  10. - name: restart nginx
  11. become: true
  12. ansible.builtin.systemd:
  13. state: restarted
  14. name: nginx
  15. - name: enable certbot sync
  16. become: true
  17. ansible.builtin.cron:
  18. name: "renew certbot every month"
  19. special_time: monthly
  20. job: "/usr/bin/certbot renew --force-renewal"