scaleup.yml 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ---
  2. - name: Gather facts
  3. hosts: oo_etcd_to_config:oo_new_etcd_to_config
  4. roles:
  5. - openshift_etcd_facts
  6. post_tasks:
  7. - set_fact:
  8. etcd_hostname: "{{ etcd_hostname }}"
  9. etcd_ip: "{{ etcd_ip }}"
  10. - name: Configure etcd
  11. hosts: oo_new_etcd_to_config
  12. serial: 1
  13. any_errors_fatal: true
  14. vars:
  15. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  16. pre_tasks:
  17. - name: Add new etcd members to cluster
  18. command: >
  19. /usr/bin/etcdctl --cert-file {{ etcd_peer_cert_file }}
  20. --key-file {{ etcd_peer_key_file }}
  21. --ca-file {{ etcd_peer_ca_file }}
  22. -C {{ etcd_peer_url_scheme }}://{{ hostvars[etcd_ca_host].etcd_ip }}:{{ etcd_client_port }}
  23. member add {{ etcd_hostname }} {{ etcd_peer_url_scheme }}://{{ etcd_ip }}:{{ etcd_peer_port }}
  24. delegate_to: "{{ etcd_ca_host }}"
  25. failed_when:
  26. - etcd_add_check.rc == 1
  27. - ("peerURL exists" not in etcd_add_check.stderr)
  28. register: etcd_add_check
  29. retries: 3
  30. delay: 10
  31. until: etcd_add_check.rc == 0
  32. - import_role:
  33. name: etcd
  34. tasks_from: server_certificates.yml
  35. vars:
  36. etcd_peers: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
  37. etcd_certificates_etcd_hosts: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
  38. roles:
  39. - role: os_firewall
  40. when: etcd_add_check.rc == 0
  41. - role: openshift_etcd
  42. when: etcd_add_check.rc == 0
  43. etcd_peers: "{{ groups.oo_etcd_to_config | union(groups.oo_new_etcd_to_config)| default([], true) }}"
  44. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  45. etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"
  46. etcd_initial_cluster_state: "existing"
  47. etcd_initial_cluster: "{{ etcd_add_check.stdout_lines[3] | regex_replace('ETCD_INITIAL_CLUSTER=','') | regex_replace('\"','') }}"
  48. etcd_ca_setup: False
  49. - role: nickhammond.logrotate
  50. when: etcd_add_check.rc == 0
  51. post_tasks:
  52. - name: Verify cluster is stable
  53. command: >
  54. /usr/bin/etcdctl --cert-file {{ etcd_peer_cert_file }}
  55. --key-file {{ etcd_peer_key_file }}
  56. --ca-file {{ etcd_peer_ca_file }}
  57. -C {{ etcd_peer_url_scheme }}://{{ hostvars[etcd_ca_host].etcd_hostname }}:{{ etcd_client_port }}
  58. cluster-health
  59. register: scaleup_health
  60. retries: 3
  61. delay: 30
  62. until: scaleup_health.rc == 0
  63. - name: Update master etcd client urls
  64. hosts: oo_masters_to_config
  65. serial: 1
  66. vars:
  67. etcd_ca_host: "{{ groups.oo_etcd_to_config.0 }}"
  68. openshift_ca_host: "{{ groups.oo_first_master.0 }}"
  69. openshift_master_etcd_hosts: "{{ hostvars
  70. | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | union(groups['oo_new_etcd_to_config'] | default([]) ))
  71. | lib_utils_oo_collect('openshift.common.hostname')
  72. | default(none, true) }}"
  73. openshift_master_etcd_port: "{{ (etcd_client_port | default('2379')) if (groups.oo_etcd_to_config is defined and groups.oo_etcd_to_config) else none }}"
  74. roles:
  75. - role: openshift_master_facts
  76. post_tasks:
  77. - import_role:
  78. name: openshift_master
  79. tasks_from: update_etcd_client_urls.yml