scaleup.yml 3.7 KB

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