distribute_ca.yml 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. ---
  2. - name: Create a tarball of the etcd ca certs
  3. command: >
  4. tar -czvf {{ etcd_conf_dir }}/{{ etcd_ca_name }}.tgz
  5. -C {{ etcd_ca_dir }} .
  6. args:
  7. creates: "{{ etcd_conf_dir }}/{{ etcd_ca_name }}.tgz"
  8. warn: no
  9. delegate_to: "{{ etcd_ca_host }}"
  10. run_once: true
  11. - name: Retrieve etcd ca cert tarball
  12. fetch:
  13. src: "{{ etcd_conf_dir }}/{{ etcd_ca_name }}.tgz"
  14. dest: "{{ etcd_sync_cert_dir }}/"
  15. flat: yes
  16. fail_on_missing: yes
  17. validate_checksum: yes
  18. delegate_to: "{{ etcd_ca_host }}"
  19. run_once: true
  20. - name: Ensure ca directory exists
  21. file:
  22. path: "{{ etcd_ca_dir }}"
  23. state: directory
  24. - name: Unarchive etcd ca cert tarballs
  25. unarchive:
  26. src: "{{ etcd_sync_cert_dir }}/{{ etcd_ca_name }}.tgz"
  27. dest: "{{ etcd_ca_dir }}"
  28. - name: Read current etcd CA
  29. slurp:
  30. src: "{{ etcd_conf_dir }}/ca.crt"
  31. register: g_current_etcd_ca_output
  32. - name: Read new etcd CA
  33. slurp:
  34. src: "{{ etcd_ca_dir }}/ca.crt"
  35. register: g_new_etcd_ca_output
  36. - copy:
  37. content: "{{ (g_new_etcd_ca_output.content|b64decode) + (g_current_etcd_ca_output.content|b64decode) }}"
  38. dest: "{{ item }}/ca.crt"
  39. with_items:
  40. - "{{ etcd_conf_dir }}"
  41. - "{{ etcd_ca_dir }}"