server.yml 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  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_server_certs | default([]) }}"
  8. - name: Create the server csr
  9. command: >
  10. openssl req -new -keyout {{ item.etcd_cert_prefix }}server.key
  11. -config {{ etcd_openssl_conf }}
  12. -out {{ item.etcd_cert_prefix }}server.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 ~ 'server.csr' }}"
  19. environment:
  20. SAN: "IP:{{ item.etcd_ip }}"
  21. with_items: "{{ etcd_needing_server_certs | default([]) }}"
  22. - name: Sign and create the server crt
  23. command: >
  24. openssl ca -name {{ etcd_ca_name }} -config {{ etcd_openssl_conf }}
  25. -out {{ item.etcd_cert_prefix }}server.crt
  26. -in {{ item.etcd_cert_prefix }}server.csr
  27. -extensions {{ etcd_ca_exts_server }} -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 ~ 'server.crt' }}"
  32. environment:
  33. SAN: "IP:{{ item.etcd_ip }}"
  34. with_items: "{{ etcd_needing_server_certs | default([]) }}"
  35. - name: Create the peer csr
  36. command: >
  37. openssl req -new -keyout {{ item.etcd_cert_prefix }}peer.key
  38. -config {{ etcd_openssl_conf }}
  39. -out {{ item.etcd_cert_prefix }}peer.csr
  40. -reqexts {{ etcd_req_ext }} -batch -nodes
  41. -subj /CN={{ item.etcd_hostname }}
  42. args:
  43. chdir: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}"
  44. creates: "{{ etcd_generated_certs_dir ~ '/' ~ item.etcd_cert_subdir ~ '/'
  45. ~ item.etcd_cert_prefix ~ 'peer.csr' }}"
  46. environment:
  47. SAN: "IP:{{ item.etcd_ip }}"
  48. with_items: "{{ etcd_needing_server_certs | default([]) }}"
  49. - name: Sign and create the peer crt
  50. command: >
  51. openssl ca -name {{ etcd_ca_name }} -config {{ etcd_openssl_conf }}
  52. -out {{ item.etcd_cert_prefix }}peer.crt
  53. -in {{ item.etcd_cert_prefix }}peer.csr
  54. -extensions {{ etcd_ca_exts_peer }} -batch
  55. args:
  56. chdir: "{{ etcd_generated_certs_dir }}/{{ item.etcd_cert_subdir }}"
  57. creates: "{{ etcd_generated_certs_dir ~ '/' ~ item.etcd_cert_subdir ~ '/'
  58. ~ item.etcd_cert_prefix ~ 'peer.crt' }}"
  59. environment:
  60. SAN: "IP:{{ item.etcd_ip }}"
  61. with_items: "{{ etcd_needing_server_certs | default([]) }}"
  62. - file:
  63. src: "{{ etcd_ca_cert }}"
  64. dest: "{{ etcd_generated_certs_dir}}/{{ item.etcd_cert_subdir }}/{{ item.etcd_cert_prefix }}ca.crt"
  65. state: hard
  66. with_items: "{{ etcd_needing_server_certs | default([]) }}"