main.yml 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  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. - name: Check etcd_ca_db exist
  37. stat: path="{{ etcd_ca_db }}"
  38. register: etcd_ca_db_check
  39. changed_when: false
  40. delegate_to: "{{ etcd_ca_host }}"
  41. run_once: true
  42. - name: Touch etcd_ca_db file
  43. file:
  44. path: "{{ etcd_ca_db }}"
  45. state: touch
  46. when: etcd_ca_db_check.stat.isreg is not defined
  47. delegate_to: "{{ etcd_ca_host }}"
  48. run_once: true
  49. - copy:
  50. dest: "{{ etcd_ca_serial }}"
  51. content: "01"
  52. force: no
  53. delegate_to: "{{ etcd_ca_host }}"
  54. run_once: true
  55. - command: >
  56. openssl req -config {{ etcd_openssl_conf }} -newkey rsa:4096
  57. -keyout {{ etcd_ca_key }} -new -out {{ etcd_ca_cert }}
  58. -x509 -extensions {{ etcd_ca_exts_self }} -batch -nodes
  59. -days {{ etcd_ca_default_days }}
  60. -subj /CN=etcd-signer@{{ ansible_date_time.epoch }}
  61. args:
  62. chdir: "{{ etcd_ca_dir }}"
  63. creates: "{{ etcd_ca_cert }}"
  64. environment:
  65. SAN: 'etcd-signer'
  66. delegate_to: "{{ etcd_ca_host }}"
  67. run_once: true