ssl.yml 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. ---
  2. - name: SSL... Create ssl certificates Directory
  3. file:
  4. dest: "{{ ssl_path }}"
  5. owner: root
  6. group: root
  7. state: directory
  8. recurse: yes
  9. - name: SSL... Create private key (RSA, 4096 bits)
  10. openssl_privatekey:
  11. path: "{{ ssl_path }}/{{ ansible_fqdn }}.key"
  12. - name: SSL... Check if CRT exists
  13. stat:
  14. path: "{{ ssl_path }}/{{ ansible_fqdn }}.crt"
  15. register: result_crt
  16. - name: SSL... Create certificate signing request (CSR) for self-signed certificate
  17. community.crypto.openssl_csr_pipe:
  18. privatekey_path: "{{ ssl_path }}/{{ ansible_fqdn }}.key"
  19. country_name: BE
  20. locality_name: Louvain-la-Neuve
  21. common_name: "{{ ansible_fqdn }}"
  22. organization_name: UCLouvain
  23. organizational_unit_name: ELIC
  24. register: csr
  25. when: (result_crt.stat.isreg is undefined) or (not result_crt.stat.isreg)
  26. - name: SSL... Generate a Self Signed OpenSSL certificate
  27. community.crypto.x509_certificate:
  28. path: "{{ ssl_path }}/{{ ansible_fqdn }}.crt"
  29. csr_content: "{{ csr.csr }}"
  30. privatekey_path: "{{ ssl_path }}/{{ ansible_fqdn }}.key"
  31. provider: selfsigned
  32. when: (result_crt.stat.isreg is undefined) or (not result_crt.stat.isreg)
  33. #- name: SSL... Remove previous PEM file
  34. # file:
  35. # path: "{{ ssl_path }}/{{ ansible_fqdn }}.pem"
  36. # state: absent
  37. - name: SSL... Merge KEY and CRT to generate PEM
  38. shell: "echo '' > {{ ssl_path }}/{{ ansible_fqdn }}.pem; cat {{ ssl_path }}/{{ ansible_fqdn }}.key {{ ssl_path }}/{{ ansible_fqdn }}.crt >> {{ ssl_path }}/{{ ansible_fqdn }}.pem"
  39. - name: SSL... Generate DH Parameters with a different size (2048 bits)
  40. community.crypto.openssl_dhparam:
  41. path: "{{ ssl_path }}/dhparams.pem"
  42. size: 2048
  43. register: dhparam