scaleup.yml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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. - import_playbook: ../../playbooks/openshift-node/scaleup.yml
  41. - name: wait for nodes to join
  42. hosts: new_workers
  43. tasks:
  44. - name: HACK disable selinux
  45. selinux:
  46. policy: targeted
  47. state: permissive
  48. - name: Create core user for storage tests to pass
  49. user:
  50. name: core
  51. group: wheel
  52. - name: Make sure core user has ssh config directory
  53. file:
  54. name: /home/core/.ssh
  55. state: directory
  56. owner: core
  57. group: wheel
  58. mode: 0700
  59. - name: Install nfs-utils for storage tests
  60. package:
  61. name: nfs-utils
  62. state: present
  63. - name: Wait for new nodes to be ready
  64. oc_obj:
  65. kubeconfig: "{{ kubeconfig_path }}"
  66. state: list
  67. kind: node
  68. name: "{{ node_name }}"
  69. delegate_to: localhost
  70. register: new_machine
  71. until:
  72. - new_machine.results is defined
  73. - new_machine.results.returncode is defined
  74. - new_machine.results.results is defined
  75. - new_machine.results.returncode == 0
  76. - new_machine.results.results[0].status is defined
  77. - new_machine.results.results[0].status.conditions is defined
  78. - new_machine.results.results[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  79. # Give the node three minutes to come back online.
  80. retries: 48
  81. delay: 30
  82. ignore_errors: true
  83. - when: new_machine is failed
  84. block:
  85. - name: Collect a list of containers
  86. command: crictl ps -a -q
  87. register: crictl_ps_output
  88. - name: Collect container logs
  89. command: "crictl logs {{ item }}"
  90. register: crictl_logs_output
  91. with_items: "{{ crictl_ps_output.stdout_lines }}"
  92. ignore_errors: true
  93. - name: Get crio logs
  94. command: journalctl --no-pager -u cri-o
  95. register: crio_logs
  96. ignore_errors: true
  97. - name: Get kubelet logs
  98. command: journalctl --no-pager -u kubelet
  99. register: kubelet_logs
  100. ignore_errors: tru
  101. - debug:
  102. var: crictl_logs_output
  103. - debug:
  104. msg: "{{ kubelet_logs.stdout_lines }}"
  105. - debug:
  106. msg: "{{ crio_logs.stdout_lines }}"
  107. - fail:
  108. msg: Node failed to become Ready
  109. - name: Remove CoreOS nodes
  110. hosts: localhost
  111. connection: local
  112. tasks:
  113. - name: Mark CoreOS nodes as unschedulable
  114. command: >
  115. oc adm cordon {{ item | lower }}
  116. --config={{ kubeconfig_path }}
  117. with_items: "{{ pre_scaleup_workers_name }}"
  118. - name: Drain CoreOS nodes
  119. command: >
  120. oc adm drain {{ item | lower }}
  121. --config={{ kubeconfig_path }}
  122. --force --delete-local-data --ignore-daemonsets
  123. --timeout=0s
  124. with_items: "{{ pre_scaleup_workers_name }}"
  125. - name: remove existing machinesets
  126. oc_obj:
  127. state: absent
  128. kind: machinesets.machine.openshift.io
  129. namespace: openshift-machine-api
  130. name: "{{ item }}"
  131. kubeconfig: "{{ kubeconfig_path }}"
  132. with_items: "{{ pre_scaleup_machineset_names }}"
  133. - name: Delete CoreOS nodes
  134. oc_obj:
  135. kubeconfig: "{{ kubeconfig_path }}"
  136. state: absent
  137. kind: node
  138. name: "{{ item }}"
  139. with_items: "{{ pre_scaleup_workers_name }}"