main.yml 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. ---
  2. - name: Install openssl
  3. action: "{{ ansible_pkg_mgr }} name=openssl state=present"
  4. when: not etcd_is_atomic | bool
  5. delegate_to: "{{ etcd_ca_host }}"
  6. run_once: true
  7. - file:
  8. path: "{{ item }}"
  9. state: directory
  10. mode: 0700
  11. owner: root
  12. group: root
  13. with_items:
  14. - "{{ etcd_ca_new_certs_dir }}"
  15. - "{{ etcd_ca_crl_dir }}"
  16. - "{{ etcd_ca_dir }}/fragments"
  17. delegate_to: "{{ etcd_ca_host }}"
  18. run_once: true
  19. - command: cp /etc/pki/tls/openssl.cnf ./
  20. args:
  21. chdir: "{{ etcd_ca_dir }}/fragments"
  22. creates: "{{ etcd_ca_dir }}/fragments/openssl.cnf"
  23. delegate_to: "{{ etcd_ca_host }}"
  24. run_once: true
  25. - template:
  26. dest: "{{ etcd_ca_dir }}/fragments/openssl_append.cnf"
  27. src: openssl_append.j2
  28. backup: true
  29. delegate_to: "{{ etcd_ca_host }}"
  30. run_once: true
  31. - assemble:
  32. src: "{{ etcd_ca_dir }}/fragments"
  33. dest: "{{ etcd_openssl_conf }}"
  34. delegate_to: "{{ etcd_ca_host }}"
  35. run_once: true
  36. - command: touch {{ etcd_ca_db }}
  37. args:
  38. creates: "{{ etcd_ca_db }}"
  39. delegate_to: "{{ etcd_ca_host }}"
  40. run_once: true
  41. - copy:
  42. dest: "{{ etcd_ca_serial }}"
  43. content: "01"
  44. force: no
  45. delegate_to: "{{ etcd_ca_host }}"
  46. run_once: true
  47. - command: >
  48. openssl req -config {{ etcd_openssl_conf }} -newkey rsa:4096
  49. -keyout {{ etcd_ca_key }} -new -out {{ etcd_ca_cert }}
  50. -x509 -extensions {{ etcd_ca_exts_self }} -batch -nodes
  51. -days {{ etcd_ca_default_days }}
  52. -subj /CN=etcd-signer@{{ ansible_date_time.epoch }}
  53. args:
  54. chdir: "{{ etcd_ca_dir }}"
  55. creates: "{{ etcd_ca_cert }}"
  56. environment:
  57. SAN: 'etcd-signer'
  58. delegate_to: "{{ etcd_ca_host }}"
  59. run_once: true