scaleup.yml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  1. ---
  2. - name: create new nodes
  3. hosts: localhost
  4. connection: local
  5. tasks:
  6. - import_tasks: ssh_bastion.yml
  7. - import_tasks: get_machinesets.yml
  8. - include_tasks: create_machineset.yml
  9. loop: "{{ machineset.resources }}"
  10. when:
  11. - item.status.replicas is defined
  12. - item.status.replicas != 0
  13. - name: wait for nodes to become available
  14. hosts: new_workers
  15. gather_facts: false
  16. tasks:
  17. - wait_for_connection: {}
  18. - setup: {}
  19. - name: Copy ops-mirror.pem
  20. copy:
  21. src: ../../inventory/dynamic/injected/ops-mirror.pem
  22. dest: /var/lib/yum/ops-mirror.pem
  23. owner: root
  24. group: root
  25. mode: 0644
  26. - name: Initialize openshift repos
  27. import_tasks: additional_repos.yml
  28. - import_playbook: ../../playbooks/scaleup.yml
  29. vars:
  30. openshift_kubeconfig_path: "{{ kubeconfig_path }}"
  31. - name: wait for nodes to join
  32. hosts: new_workers
  33. tasks:
  34. - name: HACK disable selinux
  35. selinux:
  36. policy: targeted
  37. state: permissive
  38. - name: Create core user for storage tests to pass
  39. user:
  40. name: core
  41. group: wheel
  42. - name: Make sure core user has ssh config directory
  43. file:
  44. name: /home/core/.ssh
  45. state: directory
  46. owner: core
  47. group: wheel
  48. mode: 0700
  49. - name: Install nfs-utils for storage tests
  50. package:
  51. name: nfs-utils
  52. state: present
  53. register: result
  54. until: result is succeeded
  55. - name: Wait for new nodes to be ready
  56. k8s_facts:
  57. kubeconfig: "{{ kubeconfig_path }}"
  58. kind: Node
  59. name: "{{ node_name }}"
  60. delegate_to: localhost
  61. register: new_machine
  62. until:
  63. - new_machine.resources is defined
  64. - new_machine.resources | length > 0
  65. - new_machine.resources[0].status is defined
  66. - new_machine.resources[0].status.conditions is defined
  67. - new_machine.resources[0].status.conditions | selectattr('type', 'match', '^Ready$') | map(attribute='status') | join | bool == True
  68. # Give the node three minutes to come back online.
  69. retries: 48
  70. delay: 30
  71. ignore_errors: true
  72. - when: new_machine is failed
  73. block:
  74. - name: Collect a list of containers
  75. command: crictl ps -a -q
  76. ignore_errors: true
  77. register: crictl_ps_output
  78. - name: Collect container logs
  79. command: "crictl logs {{ item }}"
  80. register: crictl_logs_output
  81. with_items: "{{ crictl_ps_output.stdout_lines }}"
  82. ignore_errors: true
  83. - name: Get crio logs
  84. command: journalctl --no-pager -u crio
  85. register: crio_logs
  86. ignore_errors: true
  87. - name: Get kubelet logs
  88. command: journalctl --no-pager -u kubelet
  89. register: kubelet_logs
  90. ignore_errors: tru
  91. - debug:
  92. var: crictl_logs_output
  93. - debug:
  94. msg: "{{ kubelet_logs.stdout_lines }}"
  95. - debug:
  96. msg: "{{ crio_logs.stdout_lines }}"
  97. - fail:
  98. msg: Node failed to become Ready
  99. - name: Remove CoreOS nodes
  100. hosts: localhost
  101. connection: local
  102. tasks:
  103. - name: Mark CoreOS nodes as unschedulable
  104. command: >
  105. oc adm cordon {{ item | lower }}
  106. --config={{ kubeconfig_path }}
  107. with_items: "{{ pre_scaleup_workers_name }}"
  108. - name: Drain CoreOS nodes
  109. command: >
  110. oc adm drain {{ item | lower }}
  111. --config={{ kubeconfig_path }}
  112. --force --delete-local-data --ignore-daemonsets
  113. --timeout=0s
  114. with_items: "{{ pre_scaleup_workers_name }}"
  115. - name: remove existing machinesets
  116. k8s:
  117. api_version: machine.openshift.io/v1beta1
  118. kubeconfig: "{{ kubeconfig_path }}"
  119. namespace: openshift-machine-api
  120. kind: MachineSet
  121. name: "{{ item }}"
  122. state: absent
  123. with_items: "{{ pre_scaleup_machineset_names }}"
  124. - name: Wait for worker configs to roll out
  125. command: oc wait machineconfigpool/worker --for=condition=Updated --timeout=5m