certificates-backup.yml 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. ---
  2. - name: Backup and remove master cerftificates
  3. hosts: oo_masters_to_config
  4. any_errors_fatal: true
  5. vars:
  6. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  7. openshift_master_count: "{{ openshift.master.master_count | default(groups.oo_masters | length) }}"
  8. pre_tasks:
  9. - stat:
  10. path: "{{ openshift.common.config_base }}/generated-configs"
  11. register: openshift_generated_configs_dir_stat
  12. - name: Backup generated certificate and config directories
  13. command: >
  14. tar -czvf /etc/origin/master-node-cert-config-backup-{{ ansible_date_time.epoch }}.tgz
  15. {{ openshift.common.config_base }}/generated-configs
  16. {{ openshift.common.config_base }}/master
  17. when: openshift_generated_configs_dir_stat.stat.exists
  18. delegate_to: "{{ openshift_ca_host }}"
  19. run_once: true
  20. - name: Remove generated certificate directories
  21. file:
  22. path: "{{ item }}"
  23. state: absent
  24. with_items:
  25. - "{{ openshift.common.config_base }}/generated-configs"
  26. - name: Remove generated certificates
  27. file:
  28. path: "{{ openshift.common.config_base }}/master/{{ item }}"
  29. state: absent
  30. with_items:
  31. # certificates_to_synchronize is a custom filter in lib_utils
  32. - "{{ hostvars[inventory_hostname] | certificates_to_synchronize(include_keys=false, include_ca=false) }}"
  33. - "etcd.server.crt"
  34. - "etcd.server.key"
  35. - "master.server.crt"
  36. - "master.server.key"
  37. - "openshift-master.crt"
  38. - "openshift-master.key"
  39. - "openshift-master.kubeconfig"