deploy_ca.yml 1.9 KB

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