scaleup.yml 3.5 KB

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