masters.yml 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. ---
  2. - name: Redeploy master certificates
  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_generated_configs_dir }}"
  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_generated_configs_dir }}
  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_generated_configs_dir }}"
  26. - name: Remove generated certificates
  27. file:
  28. path: "{{ openshift.common.config_base }}/master/{{ item }}"
  29. state: absent
  30. with_items:
  31. - "{{ hostvars[inventory_hostname] | certificates_to_synchronize(include_keys=false, include_ca=false) }}"
  32. - "etcd.server.crt"
  33. - "etcd.server.key"
  34. - "master.server.crt"
  35. - "master.server.key"
  36. - "openshift-master.crt"
  37. - "openshift-master.key"
  38. - "openshift-master.kubeconfig"
  39. - name: Remove generated etcd client certificates
  40. file:
  41. path: "{{ openshift.common.config_base }}/master/{{ item }}"
  42. state: absent
  43. with_items:
  44. - "master.etcd-client.crt"
  45. - "master.etcd-client.key"
  46. when: groups.oo_etcd_to_config | default([]) | length == 0
  47. roles:
  48. - role: openshift_master_certificates
  49. openshift_master_etcd_hosts: "{{ hostvars
  50. | oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  51. | oo_collect('openshift.common.hostname')
  52. | default(none, true) }}"
  53. openshift_certificates_redeploy: true
  54. - role: lib_utils
  55. post_tasks:
  56. - yedit:
  57. src: "{{ openshift.common.config_base }}/master/master-config.yaml"
  58. key: servingInfo.namedCertificates
  59. value: "{{ openshift.master.named_certificates | default([]) | oo_named_certificates_list }}"
  60. when:
  61. - ('named_certificates' in openshift.master)
  62. - openshift.master.named_certificates | default([]) | length > 0
  63. - openshift_master_overwrite_named_certificates | default(false) | bool