certbot.yml 887 B

1234567891011121314151617181920
  1. ---
  2. - name: Create certbot directory
  3. file: path=/opt/certbot state=directory mode=0755 owner=root group=root
  4. - name: Install certbot standalone
  5. get_url:
  6. url: "{{ certbot_url }}"
  7. dest: "{{ certbot_dir }}/certbot-auto"
  8. - name: Ensure certbot-auto is executable.
  9. file:
  10. path: "{{ certbot_dir }}/certbot-auto"
  11. mode: 0755
  12. - name: Get initial certificate
  13. command: "{{ certbot_dir }}/certbot-auto certonly --non-interactive --quiet --agree-tos --email {{ certbot_email }} --standalone --pre-hook 'service nginx stop' --post-hook 'service nginx start' -d {{ deploy_server_hostname }}"
  14. notify: restart nginx
  15. - name: Add cerbot renewel cronjob
  16. cron: name="renew letsencrypt certificates" hour="0" minute="0" job="/bin/bash {{ certbot_dir }}/certbot-auto renew --non-interactive --quiet --standalone --pre-hook 'service nginx stop' --post-hook 'service nginx start'"