deploy_ca.yml 1.9 KB

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