Du kannst nicht mehr als 25 Themen auswählen Themen müssen entweder mit einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

81 Zeilen
2.7KB

  1. ---
  2. - name: letsencrypt account private key
  3. command: openssl genrsa
  4. -out "{{certificate_letsencrypt_account_key_file}}"
  5. 4096
  6. args:
  7. creates: "{{ certificate_letsencrypt_account_key_file }}"
  8. - include_tasks: key.yml
  9. - include_tasks: csr.yml
  10. - name: check if the certificate will expire soon
  11. command: openssl x509 -checkend {{ 60*60*24*30 }} -noout -in {{certificate_file}}
  12. register: _certificate_checkend
  13. changed_when: _certificate_checkend.rc == 1
  14. failed_when: _certificate_checkend.rc > 1
  15. - name: letsencrypt request
  16. letsencrypt:
  17. account_key: "{{certificate_letsencrypt_account_key_file}}"
  18. csr: "{{certificate_signing_request_file}}"
  19. dest: "{{certificate_file}}"
  20. challenge: http-01
  21. acme_directory: https://acme-v01.api.letsencrypt.org/directory
  22. agreement: https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
  23. register: _letsencrypt_request
  24. when: _certificate_checkend.rc == 1
  25. # - debug:
  26. # msg:
  27. # _letsencrypt_request: "{{_letsencrypt_request}}"
  28. - block:
  29. - name: acme http directory
  30. file:
  31. path: /var/www/default/.well-known/acme-challenge
  32. state: directory
  33. - name: copy acme challenge resource
  34. copy:
  35. dest: /var/www/default/{{ item.resource }}
  36. content: "{{ item.resource_value }}"
  37. with_items: "{{ _letsencrypt_request | json_query('challenge_data.*.\"http-01\"') }}"
  38. - letsencrypt:
  39. account_key: "{{certificate_letsencrypt_account_key_file}}"
  40. csr: "{{certificate_signing_request_file}}"
  41. dest: "{{certificate_file}}"
  42. challenge: http-01
  43. acme_directory: https://acme-v01.api.letsencrypt.org/directory
  44. agreement: https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf
  45. data: "{{ _letsencrypt_request }}"
  46. register: _letsencrypt
  47. when:
  48. - _letsencrypt_request.changed
  49. - _certificate_checkend.rc == 1
  50. - name: download letsencrypt certificate
  51. get_url:
  52. url: https://letsencrypt.org/certs/lets-encrypt-x3-cross-signed.pem.txt
  53. dest: "{{certificate_chain_file}}"
  54. checksum: sha512:0fa893f751f0880c7d89c398cae9708f5ff04d466832fb6160a824395032259ac52e02a44da531d0f8bf7e310298b0067b1e8257f816d3223034f391ecba491d
  55. - name: fetch certificate
  56. fetch:
  57. src: "{{ certificate_file }}"
  58. dest: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.cert.pem
  59. flat: yes
  60. fail_on_missing: yes
  61. - name: fetch certificate chain
  62. fetch:
  63. src: "{{ certificate_chain_file }}"
  64. dest: host_files/{{inventory_hostname}}/certificate/{{certificate_name}}.chain.pem
  65. flat: yes
  66. fail_on_missing: yes
  67. - name: create full certificate chain
  68. template:
  69. src: fullchain.pam.j2
  70. dest: "{{ certificate_fullchain_file }}"