client.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. ---
  2. - name: Ensure generated_certs directory present
  3. file:
  4. path: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}"
  5. state: directory
  6. mode: 0700
  7. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  8. - name: Create the client csr
  9. command: >
  10. openssl req -new -keyout {{ item.etcd_cert_prefix }}client.key
  11. -config {{ etcd_openssl_conf }}
  12. -out {{ item.etcd_cert_prefix }}client.csr
  13. -reqexts {{ etcd_req_ext }} -batch -nodes
  14. -subj /CN={{ item.etcd_hostname }}
  15. args:
  16. chdir: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}"
  17. creates: "{{ etcd_generated_certs_dir ~ '/' ~ item.etcd_cert_subdir ~ '/'
  18. ~ item.etcd_cert_prefix ~ 'client.csr' }}"
  19. environment:
  20. SAN: "IP:{{ item.etcd_ip }}"
  21. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  22. - name: Sign and create the client crt
  23. command: >
  24. openssl ca -name {{ etcd_ca_name }} -config {{ etcd_openssl_conf }}
  25. -out {{ item.etcd_cert_prefix }}client.crt
  26. -in {{ item.etcd_cert_prefix }}client.csr
  27. -batch
  28. args:
  29. chdir: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}"
  30. creates: "{{ etcd_generated_certs_dir ~ '/' ~ item.etcd_cert_subdir ~ '/'
  31. ~ item.etcd_cert_prefix ~ 'client.crt' }}"
  32. environment:
  33. SAN: "IP:{{ item.etcd_ip }}"
  34. with_items: "{{ etcd_needing_client_certs | default([]) }}"
  35. - file:
  36. src: "{{ etcd_ca_cert }}"
  37. dest: "{{ etcd_generated_certs_dir}}/{{ item.etcd_cert_subdir }}/{{ item.etcd_cert_prefix }}ca.crt"
  38. state: hard
  39. with_items: "{{ etcd_needing_client_certs | default([]) }}"