scaleup.yml 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. pre_tasks:
  15. - name: Add new etcd members to cluster
  16. command: >
  17. {{ r_etcd_common_etcdctl_command }}
  18. --cert-file {{ etcd_peer_cert_file }}
  19. --key-file {{ etcd_peer_key_file }}
  20. --ca-file {{ etcd_peer_ca_file }}
  21. -C {{ etcd_peer_url_scheme }}://{{ hostvars[etcd_ca_host].etcd_ip }}:{{ etcd_client_port }}
  22. member add {{ etcd_hostname }} {{ etcd_peer_url_scheme }}://{{ etcd_ip }}:{{ etcd_peer_port }}
  23. delegate_to: "{{ etcd_ca_host }}"
  24. failed_when:
  25. - etcd_add_check.rc == 1
  26. - ("peerURL exists" not in etcd_add_check.stderr)
  27. register: etcd_add_check
  28. retries: 3
  29. delay: 10
  30. until: etcd_add_check.rc == 0
  31. - import_role:
  32. name: etcd
  33. tasks_from: server_certificates.yml
  34. vars:
  35. etcd_peers: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
  36. etcd_certificates_etcd_hosts: "{{ groups.oo_new_etcd_to_config | default([], true) }}"
  37. roles:
  38. - role: os_firewall
  39. when: etcd_add_check.rc == 0
  40. - role: openshift_etcd
  41. when: etcd_add_check.rc == 0
  42. etcd_peers: "{{ groups.oo_etcd_to_config | union(groups.oo_new_etcd_to_config)| default([], true) }}"
  43. etcd_certificates_etcd_hosts: "{{ groups.oo_etcd_to_config | default([], true) }}"
  44. etcd_initial_cluster_state: "existing"
  45. etcd_initial_cluster: "{{ etcd_add_check.stdout_lines[3] | regex_replace('ETCD_INITIAL_CLUSTER=','') | regex_replace('\"','') }}"
  46. etcd_ca_setup: False
  47. - role: nickhammond.logrotate
  48. when: etcd_add_check.rc == 0
  49. post_tasks:
  50. - name: Verify cluster is stable
  51. command: >
  52. {{ r_etcd_common_etcdctl_command }}
  53. --cert-file {{ etcd_peer_cert_file }}
  54. --key-file {{ etcd_peer_key_file }}
  55. --ca-file {{ etcd_peer_ca_file }}
  56. -C {{ etcd_peer_url_scheme }}://{{ hostvars[etcd_ca_host].etcd_hostname }}:{{ etcd_client_port }}
  57. cluster-health
  58. register: scaleup_health
  59. retries: 3
  60. delay: 30
  61. until: scaleup_health.rc == 0
  62. - name: Update master etcd client urls
  63. hosts: oo_masters_to_config
  64. serial: 1
  65. pre_tasks:
  66. - set_fact:
  67. openshift_master_etcd_hosts: "{{ hostvars
  68. | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | union(groups['oo_new_etcd_to_config'] | default([]) ))
  69. | lib_utils_oo_collect('openshift.common.hostname')
  70. | default(none, true) }}"
  71. openshift_master_etcd_port: "{{ etcd_client_port | default('2379') }}"
  72. openshift_no_proxy_etcd_host_ips: "{{ hostvars | lib_utils_oo_select_keys(groups['oo_etcd_to_config'] | default([]))
  73. | lib_utils_oo_collect('openshift.common.ip') | default([]) | join(',')
  74. }}"
  75. # This fact requires the facts set above, so needs to happen in it's own task.
  76. - set_fact:
  77. # lib_utils_oo_etcd_host_urls is a custom filter plugin in roles/lib_utils/filter_plugins/oo_filters.py
  78. openshift_master_etcd_urls: "{{ openshift_master_etcd_hosts | lib_utils_oo_etcd_host_urls(l_use_ssl, openshift_master_etcd_port) }}"
  79. vars:
  80. l_use_ssl: "{{ openshift_master_etcd_use_ssl | default(True) | bool}}"
  81. roles:
  82. - role: openshift_master_facts
  83. post_tasks:
  84. - import_role:
  85. name: openshift_master
  86. tasks_from: update_etcd_client_urls.yml