authority.yml 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. ---
  2. - name: Install openssl
  3. apt:
  4. update_cache: yes
  5. state: present
  6. pkg:
  7. - openssl
  8. - name: Make certificates directory
  9. file:
  10. path: "{{ ca_cert_dir }}"
  11. state: directory
  12. - name: Certification Authority - Check if the private key is already present
  13. stat:
  14. path: "{{ ca_cert_dir }}/{{ ca_cert_name }}.key"
  15. register: ca_cert_key
  16. - name: Certification Authority - Generate the CA private key
  17. shell: openssl genrsa -des3 -passout pass:"{{ ca_cert_key_pass }}" -out {{ ca_cert_name }}.key 4096
  18. args:
  19. chdir: "{{ ca_cert_dir }}"
  20. when: not ca_cert_key.stat.exists
  21. - name: Certification Authority - Check if the CA root certificate is already presentt
  22. stat:
  23. path: "{{ ca_cert_dir }}/{{ ca_cert_name }}.pem"
  24. register: ca_cert_pem
  25. - name: Certification Authority - Generate the CA root configuration file
  26. template:
  27. src: authority.conf.j2
  28. dest: "{{ ca_cert_dir }}/{{ ca_cert_name }}.conf"
  29. when: not ca_cert_pem.stat.exists
  30. - name: Certification Authority - Generate the CA root certificate
  31. shell: openssl req -x509 -new -nodes \
  32. -key {{ ca_cert_name }}.key \
  33. -passin pass:"{{ ca_cert_key_pass }}" \
  34. -sha256 -days {{ ca_cert_days }} -out {{ ca_cert_name }}.pem \
  35. -config {{ ca_cert_name }}.conf
  36. args:
  37. chdir: "{{ ca_cert_dir }}"
  38. when: not ca_cert_pem.stat.exists