Matrix Docker Ansible eploy
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

70 строки
2.7 KiB

  1. - debug:
  2. msg: "Dealing with SSL certificate retrieval for domain: {{ domain_name }}"
  3. - set_fact:
  4. domain_name_certificate_path: "{{ matrix_ssl_config_dir_path }}/live/{{ domain_name }}/cert.pem"
  5. - name: Check if a certificate for the domain already exists
  6. stat:
  7. path: "{{ domain_name_certificate_path }}"
  8. register: domain_name_certificate_path_stat
  9. - set_fact:
  10. domain_name_needs_cert: "{{ not domain_name_certificate_path_stat.stat.exists }}"
  11. # This will fail if there is something running on port 80 (like matrix-nginx-proxy).
  12. # We suppress the error, as we'll try another method below.
  13. - name: Attempt initial SSL certificate retrieval with standalone authenticator (directly)
  14. shell: >-
  15. /usr/bin/docker run
  16. --rm
  17. --name=matrix-certbot
  18. --net=host
  19. -v {{ matrix_ssl_config_dir_path }}:/etc/letsencrypt
  20. -v {{ matrix_ssl_log_dir_path }}:/var/log/letsencrypt
  21. {{ matrix_ssl_certbot_docker_image }}
  22. certonly
  23. --non-interactive
  24. {% if matrix_ssl_use_staging %}--staging{% endif %}
  25. --standalone
  26. --preferred-challenges http
  27. --agree-tos
  28. --email={{ matrix_ssl_support_email }}
  29. -d {{ domain_name }}
  30. when: "domain_name_needs_cert"
  31. register: result_certbot_direct
  32. ignore_errors: true
  33. # If matrix-nginx-proxy is configured from a previous run of this playbook,
  34. # and it's running now, it may be able to proxy requests to `matrix_ssl_certbot_standalone_http_port`.
  35. - name: Attempt initial SSL certificate retrieval with standalone authenticator (via proxy)
  36. shell: >-
  37. /usr/bin/docker run
  38. --rm
  39. --name=matrix-certbot
  40. -p 127.0.0.1:{{ matrix_ssl_certbot_standalone_http_port }}:80
  41. --network={{ matrix_docker_network }}
  42. -v {{ matrix_ssl_config_dir_path }}:/etc/letsencrypt
  43. -v {{ matrix_ssl_log_dir_path }}:/var/log/letsencrypt
  44. {{ matrix_ssl_certbot_docker_image }}
  45. certonly
  46. --non-interactive
  47. {% if matrix_ssl_use_staging %}--staging{% endif %}
  48. --standalone
  49. --preferred-challenges http
  50. --agree-tos
  51. --email={{ matrix_ssl_support_email }}
  52. -d {{ domain_name }}
  53. when: "domain_name_needs_cert and result_certbot_direct.failed"
  54. register: result_certbot_proxy
  55. ignore_errors: true
  56. - name: Fail if all SSL certificate retrieval attempts failed
  57. fail:
  58. msg: |
  59. Failed to obtain a certificate directly (by listening on port 80)
  60. and also failed to obtain by relying on the server at port 80 to proxy the request.
  61. See above for details.
  62. You may wish to set up proxying of /.well-known/acme-challenge to {{ matrix_ssl_certbot_standalone_http_port }} or,
  63. more easily, stop the server on port 80 while this playbook runs.
  64. when: "domain_name_needs_cert and result_certbot_direct.failed and result_certbot_proxy.failed"