scaleup.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. ---
  2. - name: run the init
  3. import_playbook: ../../playbooks/init/main.yml
  4. vars:
  5. l_init_fact_hosts: "all:!all"
  6. l_openshift_version_set_hosts: "all:!all"
  7. - name: create new nodes
  8. hosts: localhost
  9. connection: local
  10. tasks:
  11. - name: add localhost as master
  12. add_host:
  13. name: localhost
  14. ansible_connection: local
  15. groups: masters
  16. - import_tasks: get_machinesets.yml
  17. - include_tasks: create_machineset.yml
  18. loop: "{{ machineset.results.results[0]['items'] }}"
  19. when:
  20. - item.status.replicas is defined
  21. - item.status.replicas != 0
  22. - name: wait for nodes to become available
  23. hosts: new_workers
  24. gather_facts: false
  25. tasks:
  26. - wait_for_connection: {}
  27. - setup: {}
  28. - import_playbook: ../../playbooks/openshift-node/scaleup.yml
  29. - name: wait for nodes to join
  30. hosts: new_workers
  31. tasks:
  32. - name: HACK disable selinux
  33. selinux:
  34. policy: targeted
  35. state: permissive
  36. - name: Create core user for storage tests to pass
  37. user:
  38. name: core
  39. group: wheel
  40. - name: Make sure core user has ssh config directory
  41. file:
  42. name: /home/core/.ssh
  43. state: directory
  44. owner: core
  45. group: wheel
  46. mode: 0700
  47. - name: Copy a list of authorized ssh keys
  48. copy:
  49. src: /home/ec2-user/.ssh/authorized_keys
  50. dest: /home/core/.ssh/authorized_keys
  51. remote_src: true
  52. owner: core
  53. group: wheel
  54. mode: 600
  55. - name: Install nfs-utils for storage tests
  56. package:
  57. name: nfs-utils
  58. state: present
  59. - name: Wait for new nodes to be ready
  60. oc_obj:
  61. kubeconfig: "{{ kubeconfig_path }}"
  62. state: list
  63. kind: node
  64. name: "{{ node_name }}"
  65. delegate_to: localhost
  66. register: new_machine
  67. until:
  68. - new_machine.results is defined
  69. - new_machine.results.returncode is defined
  70. - new_machine.results.results is defined
  71. - new_machine.results.returncode == 0
  72. - new_machine.results.results[0].status is defined
  73. - new_machine.results.results[0].status.conditions is defined
  74. - new_machine.results.results[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  75. # Give the node three minutes to come back online.
  76. retries: 48
  77. delay: 30
  78. ignore_errors: true
  79. - when: new_machine is failed
  80. block:
  81. - name: Collect a list of containers
  82. command: crictl ps -a -q
  83. register: crictl_ps_output
  84. - name: Collect container logs
  85. command: "crictl logs {{ item }}"
  86. register: crictl_logs_output
  87. with_items: "{{ crictl_ps_output.stdout_lines }}"
  88. ignore_errors: true
  89. - debug:
  90. var: crictl_logs_output
  91. - debug:
  92. msg: "{{ bootkube_logs.stdout_lines }}"
  93. - fail:
  94. msg: Node failed to become Ready
  95. - name: Remove CoreOS nodes
  96. hosts: localhost
  97. connection: local
  98. tasks:
  99. - name: Mark CoreOS nodes as unschedulable
  100. oc_adm_manage_node:
  101. kubeconfig: "{{ kubeconfig_path }}"
  102. node: "{{ item }}"
  103. schedulable: False
  104. with_items: "{{ pre_scaleup_workers_name }}"
  105. - name: Drain CoreOS nodes
  106. command: >
  107. oc adm drain {{ item | lower }}
  108. --config={{ kubeconfig_path }}
  109. --force --delete-local-data --ignore-daemonsets
  110. --timeout=0s
  111. with_items: "{{ pre_scaleup_workers_name }}"
  112. - name: remove existing machinesets
  113. oc_obj:
  114. state: absent
  115. kind: machinesets
  116. namespace: openshift-cluster-api
  117. name: "{{ item }}"
  118. kubeconfig: "{{ kubeconfig_path }}"
  119. with_items: "{{ pre_scaleup_machineset_names }}"
  120. - name: Delete CoreOS nodes
  121. oc_obj:
  122. kubeconfig: "{{ kubeconfig_path }}"
  123. state: absent
  124. kind: node
  125. name: "{{ item }}"
  126. with_items: "{{ pre_scaleup_workers_name }}"