From 90367d1e26b516b97b514a94edc5e137482c997f Mon Sep 17 00:00:00 2001 From: Joe LeVeque Date: Thu, 22 Mar 2018 01:24:31 +0000 Subject: [PATCH] Unify style of 'wait_for' actions across playbooks --- ansible/boot_onie.yml | 38 ++++++++++--------- ansible/roles/sonic-common/tasks/main.yml | 8 +++- .../test/tasks/common_tasks/reboot_sonic.yml | 13 ++++--- ansible/roles/test/tasks/saiserver.yml | 3 +- ansible/roles/test/tasks/service_acl.yml | 26 ++++++------- ansible/roles/test/tasks/syslog.yml | 3 +- ansible/upgrade_sonic.yml | 35 +++++++++-------- 7 files changed, 71 insertions(+), 55 deletions(-) diff --git a/ansible/boot_onie.yml b/ansible/boot_onie.yml index 3459604e1fd..e84b788913b 100644 --- a/ansible/boot_onie.yml +++ b/ansible/boot_onie.yml @@ -28,37 +28,41 @@ - name: Wait for switch to come back (to ONIE) local_action: - wait_for host={{ real_ansible_host }} - port=22 - state=started - delay=60 - timeout=300 + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: started + delay: 60 + timeout: 300 become: false changed_when: false - name: Wait for switch to reboot again local_action: - wait_for host={{ real_ansible_host }} - port=22 - state=stopped - delay=5 - timeout=600 + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: stopped + delay: 5 + timeout: 600 become: false changed_when: false - name: Wait for switch to come back (to SONiC) local_action: - wait_for host={{ real_ansible_host }} - port=22 - state=started - delay=30 - timeout=600 - search_regex=OpenSSH + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: started + search_regex: "OpenSSH" + delay: 30 + timeout: 600 become: false changed_when: false - name: Wait for the SONiC initialization process - pause: seconds=60 + pause: + seconds: 60 - name: Set all bgp interfaces admin-up become: true diff --git a/ansible/roles/sonic-common/tasks/main.yml b/ansible/roles/sonic-common/tasks/main.yml index 1ea562d3c52..f6dbf9f6431 100644 --- a/ansible/roles/sonic-common/tasks/main.yml +++ b/ansible/roles/sonic-common/tasks/main.yml @@ -243,7 +243,13 @@ tags: unsafe - name: After rebooting, wait for switch to come back - local_action: wait_for host={{ inventory_hostname }} port=22 state=started delay=30 timeout=300 + local_action: + wait_for: + host: "{{ inventory_hostname }}" + port: 22 + state: started + delay: 30 + timeout: 300 become: false when: reboot_required is defined tags: unsafe diff --git a/ansible/roles/test/tasks/common_tasks/reboot_sonic.yml b/ansible/roles/test/tasks/common_tasks/reboot_sonic.yml index 56487f788ab..6755091f163 100644 --- a/ansible/roles/test/tasks/common_tasks/reboot_sonic.yml +++ b/ansible/roles/test/tasks/common_tasks/reboot_sonic.yml @@ -9,12 +9,13 @@ - name: Wait for switch to come back local_action: - wait_for host={{ ansible_host }} - port=22 - state=started - delay=10 - timeout=180 - search_regex="OpenSSH_[\w\.]+ Debian" + wait_for: + host: "{{ ansible_host }}" + port: 22 + state: started + search_regex: "OpenSSH_[\w\.]+ Debian" + delay: 10 + timeout: 180 become: false changed_when: false diff --git a/ansible/roles/test/tasks/saiserver.yml b/ansible/roles/test/tasks/saiserver.yml index d6bf6805bed..745b4f29e61 100644 --- a/ansible/roles/test/tasks/saiserver.yml +++ b/ansible/roles/test/tasks/saiserver.yml @@ -26,7 +26,8 @@ when: no_deploy_saiserver is not defined - name: Wait to make sure saiserver is started - wait_for: timeout=20 + wait_for: + timeout: 20 - name: Run SAI Test shell: ptf --test-dir /usr/share/ptf-tests {{ tests | default ("")}} -t "server='{{ ansible_host }}';port_map_file='/etc/ptf/default_interface_to_front_map.ini'" --platform remote {{ extra_options | default("")}} 2>&1 diff --git a/ansible/roles/test/tasks/service_acl.yml b/ansible/roles/test/tasks/service_acl.yml index 77f214bbf73..cdf876bebfd 100644 --- a/ansible/roles/test/tasks/service_acl.yml +++ b/ansible/roles/test/tasks/service_acl.yml @@ -31,12 +31,12 @@ # Note that the timeout here should be sufficiently long enough to allow # config_service_acls.sh to apply the new service ACLs - name: Ensure the SSH port on the DuT becomes closed to us - wait_for: - port: 22 - state: stopped - host: "{{ ansible_host }}" - timeout: 15 - connection: local + local_action: + wait_for: + host: "{{ ansible_host }}" + port: 22 + state: stopped + timeout: 15 # Gather facts with SNMP version 2 - name: Ensure attempt to gather basic SNMP facts about the device now times out @@ -51,13 +51,13 @@ # Note that the timeout here should be sufficiently long enough to allow # config_service_acls.sh to reset the ACLs to their original configuration - name: Wait until the original service ACLs are reinstated and the SSH port on the DUT is open to us once again - wait_for: - port: 22 - state: started - host: "{{ ansible_host }}" - search_regex: "OpenSSH" - timeout: 60 - connection: local + local_action: + wait_for: + host: "{{ ansible_host }}" + port: 22 + state: started + search_regex: "OpenSSH" + timeout: 60 - name: Delete config_service_acls.sh from the DuT become: true diff --git a/ansible/roles/test/tasks/syslog.yml b/ansible/roles/test/tasks/syslog.yml index d83bbe06280..fa74c902b7f 100644 --- a/ansible/roles/test/tasks/syslog.yml +++ b/ansible/roles/test/tasks/syslog.yml @@ -91,7 +91,8 @@ service: name=rsyslog state=started - name: Wait a little bit for service to start - wait_for: timeout=2 + wait_for: + timeout: 2 # SSH to device and generate a syslog - name: Send test syslog diff --git a/ansible/upgrade_sonic.yml b/ansible/upgrade_sonic.yml index 0b0977d736a..192e42f1022 100644 --- a/ansible/upgrade_sonic.yml +++ b/ansible/upgrade_sonic.yml @@ -32,11 +32,12 @@ - name: Wait for switch to come back (to ONIE) local_action: - wait_for host={{ real_ansible_host }} - port=22 - state=started - delay=60 - timeout=300 + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: started + delay: 60 + timeout: 300 changed_when: false - name: Stop onie discovery @@ -55,11 +56,12 @@ - name: Wait for switch to reboot again (ONIE installation finishes) local_action: - wait_for host={{ real_ansible_host }} - port=22 - state=stopped - delay=5 - timeout=600 + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: stopped + delay: 5 + timeout: 600 changed_when: false when: upgrade_type == "onie" @@ -85,12 +87,13 @@ - name: Wait for switch {{ inventory_hostname }} to come back (to SONiC) local_action: - wait_for host={{ ansible_host }} - port=22 - state=started - delay=30 - timeout=600 - search_regex=OpenSSH + wait_for: + host: "{{ real_ansible_host }}" + port: 22 + state: started + search_regex: "OpenSSH" + delay: 30 + timeout: 600 changed_when: false - name: Wait for SONiC initialization