From 5e3bd2dff19810fff64a494dcb74c00d493e9199 Mon Sep 17 00:00:00 2001 From: Maxime Guyot Date: Fri, 10 May 2019 10:25:59 +0200 Subject: [PATCH] Use common playbook to wait for SSH (#4734) --- .gitlab-ci/terraform.yml | 1 + tests/cloud_playbooks/create-aws.yml | 9 --------- tests/cloud_playbooks/create-do.yml | 5 ----- tests/cloud_playbooks/create-gce.yml | 13 ------------- .../roles/packet-ci/tasks/create-vms.yml | 10 ---------- tests/cloud_playbooks/wait-for-ssh.yml | 12 ++++++++++++ tests/scripts/testcases_run.sh | 5 ++++- 7 files changed, 17 insertions(+), 38 deletions(-) create mode 100644 tests/cloud_playbooks/wait-for-ssh.yml diff --git a/.gitlab-ci/terraform.yml b/.gitlab-ci/terraform.yml index 1630fd7c2..343782167 100644 --- a/.gitlab-ci/terraform.yml +++ b/.gitlab-ci/terraform.yml @@ -37,6 +37,7 @@ CI_PLATFORM: tf script: - cd tests && make create-${CI_PLATFORM} -s ; cd - + - ansible-playbook tests/cloud_playbooks/wait-for-ssh.yml - ansible-playbook cluster.yml --become # - tests/scripts/testcases_prepare.sh after_script: diff --git a/tests/cloud_playbooks/create-aws.yml b/tests/cloud_playbooks/create-aws.yml index dcc51bdf7..eb33d9838 100644 --- a/tests/cloud_playbooks/create-aws.yml +++ b/tests/cloud_playbooks/create-aws.yml @@ -22,12 +22,3 @@ template: src: ../templates/inventory-aws.j2 dest: "{{ inventory_path }}" - - - name: Wait until SSH is available - wait_for: - host: "{{ item.public_ip }}" - port: 22 - timeout: 300 - state: started - delegate_to: localhost - with_items: "{{ ec2.instances }}" diff --git a/tests/cloud_playbooks/create-do.yml b/tests/cloud_playbooks/create-do.yml index 02fab16e4..55932a408 100644 --- a/tests/cloud_playbooks/create-do.yml +++ b/tests/cloud_playbooks/create-do.yml @@ -90,8 +90,3 @@ src: ../templates/inventory-do.j2 dest: "{{ inventory_path }}" when: state == 'present' - - - name: Wait for SSH to come up - wait_for: host={{ item.droplet.ip_address }} port=22 delay=10 timeout=180 state=started - with_items: "{{ droplets.results }}" - when: state == 'present' diff --git a/tests/cloud_playbooks/create-gce.yml b/tests/cloud_playbooks/create-gce.yml index 7f2de0dd6..61b3d852f 100644 --- a/tests/cloud_playbooks/create-gce.yml +++ b/tests/cloud_playbooks/create-gce.yml @@ -71,16 +71,3 @@ state: absent recurse: yes when: delete_group_vars - -- name: Wait for instances - hosts: "waitfor_hosts" - gather_facts: false - tasks: - - name: Wait for SSH to come up. - wait_for: - host: "{{ inventory_hostname }}" - port: 22 - delay: 60 - timeout: 240 - state: started - delegate_to: localhost diff --git a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml index 957cbf97b..a8d4ced08 100644 --- a/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml +++ b/tests/cloud_playbooks/roles/packet-ci/tasks/create-vms.yml @@ -40,16 +40,6 @@ until: - vm_ips.stdout | ipaddr -- name: Wait for SSH to become available on vms - wait_for: - host: "{{ item.stdout }}" - port: 22 - delay: 30 - timeout: 240 - state: started - with_items: - - "{{ vm_ips.results }}" - - name: "Create inventory for CI test in file /tmp/{{ test_name }}/inventory" template: src: "inventory.j2" diff --git a/tests/cloud_playbooks/wait-for-ssh.yml b/tests/cloud_playbooks/wait-for-ssh.yml new file mode 100644 index 000000000..417a541f4 --- /dev/null +++ b/tests/cloud_playbooks/wait-for-ssh.yml @@ -0,0 +1,12 @@ +--- +- hosts: all + become: False + gather_facts: False + + tasks: + - name: Wait until SSH is available + wait_for: + host: "{{ ansible_ssh_host }}" + port: 22 + timeout: 240 + delegate_to: localhost diff --git a/tests/scripts/testcases_run.sh b/tests/scripts/testcases_run.sh index 1fc387a36..3cae1a4a4 100755 --- a/tests/scripts/testcases_run.sh +++ b/tests/scripts/testcases_run.sh @@ -7,12 +7,15 @@ echo "PYPATH is $PYPATH" pwd ls echo ${PWD} -cd tests && make create-${CI_PLATFORM} -s ; cd - export ANSIBLE_REMOTE_USER=$SSH_USER export ANSIBLE_BECOME=true export ANSIBLE_BECOME_USER=root +cd tests && make create-${CI_PLATFORM} -s ; cd - +ansible-playbook tests/cloud_playbooks/wait-for-ssh.yml + + # Check out latest tag if testing upgrade test "${UPGRADE_TEST}" != "false" && git fetch --all && git checkout "$KUBESPRAY_VERSION" # Checkout the CI vars file so it is available