scaleup.yml 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  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: create temp directory
  12. command: mktemp -d /tmp/openshift-ansible-XXXXXXX
  13. register: mktemp
  14. changed_when: False
  15. - name: add localhost as master
  16. add_host:
  17. name: localhost
  18. ansible_connection: local
  19. groups: masters
  20. - import_tasks: ssh_bastion.yml
  21. - import_tasks: get_machinesets.yml
  22. - include_tasks: create_machineset.yml
  23. loop: "{{ machineset.results.results[0]['items'] }}"
  24. when:
  25. - item.status.replicas is defined
  26. - item.status.replicas != 0
  27. - name: wait for nodes to become available
  28. hosts: new_workers
  29. gather_facts: false
  30. tasks:
  31. - wait_for_connection: {}
  32. - setup: {}
  33. - name: Copy ops-mirror.pem
  34. copy:
  35. src: ../../inventory/dynamic/injected/ops-mirror.pem
  36. dest: /var/lib/yum/ops-mirror.pem
  37. owner: root
  38. group: root
  39. mode: 0644
  40. ignore_errors: true
  41. - import_playbook: ../../playbooks/openshift-node/scaleup.yml
  42. - name: wait for nodes to join
  43. hosts: new_workers
  44. tasks:
  45. - name: HACK disable selinux
  46. selinux:
  47. policy: targeted
  48. state: permissive
  49. - name: Create core user for storage tests to pass
  50. user:
  51. name: core
  52. group: wheel
  53. - name: Make sure core user has ssh config directory
  54. file:
  55. name: /home/core/.ssh
  56. state: directory
  57. owner: core
  58. group: wheel
  59. mode: 0700
  60. - name: Copy a list of authorized ssh keys
  61. copy:
  62. src: /home/ec2-user/.ssh/authorized_keys
  63. dest: /home/core/.ssh/authorized_keys
  64. remote_src: true
  65. owner: core
  66. group: wheel
  67. mode: 600
  68. - name: Install nfs-utils for storage tests
  69. package:
  70. name: nfs-utils
  71. state: present
  72. - name: Wait for new nodes to be ready
  73. oc_obj:
  74. kubeconfig: "{{ kubeconfig_path }}"
  75. state: list
  76. kind: node
  77. name: "{{ node_name }}"
  78. delegate_to: localhost
  79. register: new_machine
  80. until:
  81. - new_machine.results is defined
  82. - new_machine.results.returncode is defined
  83. - new_machine.results.results is defined
  84. - new_machine.results.returncode == 0
  85. - new_machine.results.results[0].status is defined
  86. - new_machine.results.results[0].status.conditions is defined
  87. - new_machine.results.results[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  88. # Give the node three minutes to come back online.
  89. retries: 48
  90. delay: 30
  91. ignore_errors: true
  92. - when: new_machine is failed
  93. block:
  94. - name: Collect a list of containers
  95. command: crictl ps -a -q
  96. register: crictl_ps_output
  97. - name: Collect container logs
  98. command: "crictl logs {{ item }}"
  99. register: crictl_logs_output
  100. with_items: "{{ crictl_ps_output.stdout_lines }}"
  101. ignore_errors: true
  102. - name: Get crio logs
  103. command: journalctl --no-pager -u cri-o
  104. register: crio_logs
  105. ignore_errors: true
  106. - name: Get kubelet logs
  107. command: journalctl --no-pager -u kubelet
  108. register: kubelet_logs
  109. ignore_errors: tru
  110. - debug:
  111. var: crictl_logs_output
  112. - debug:
  113. msg: "{{ kubelet_logs.stdout_lines }}"
  114. - debug:
  115. msg: "{{ crio_logs.stdout_lines }}"
  116. - fail:
  117. msg: Node failed to become Ready
  118. - name: Remove CoreOS nodes
  119. hosts: localhost
  120. connection: local
  121. tasks:
  122. - name: Mark CoreOS nodes as unschedulable
  123. oc_adm_manage_node:
  124. kubeconfig: "{{ kubeconfig_path }}"
  125. node: "{{ item }}"
  126. schedulable: False
  127. with_items: "{{ pre_scaleup_workers_name }}"
  128. - name: Drain CoreOS nodes
  129. command: >
  130. oc adm drain {{ item | lower }}
  131. --config={{ kubeconfig_path }}
  132. --force --delete-local-data --ignore-daemonsets
  133. --timeout=0s
  134. with_items: "{{ pre_scaleup_workers_name }}"
  135. - name: remove existing machinesets
  136. oc_obj:
  137. state: absent
  138. kind: machinesets.machine.openshift.io
  139. namespace: openshift-machine-api
  140. name: "{{ item }}"
  141. kubeconfig: "{{ kubeconfig_path }}"
  142. with_items: "{{ pre_scaleup_machineset_names }}"
  143. - name: Delete CoreOS nodes
  144. oc_obj:
  145. kubeconfig: "{{ kubeconfig_path }}"
  146. state: absent
  147. kind: node
  148. name: "{{ item }}"
  149. with_items: "{{ pre_scaleup_workers_name }}"