From 41948b93338965ea0c48dff15fbafbd819f350db Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Wed, 8 May 2019 08:09:39 +0000 Subject: [PATCH 1/4] [deploy] Wait for vEOS to come back after restart Signed-off-by: Xin Wang --- ansible/roles/eos/handlers/main.yml | 9 +++++++++ ansible/roles/eos/tasks/main.yml | 4 +++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/ansible/roles/eos/handlers/main.yml b/ansible/roles/eos/handlers/main.yml index ddd945ccf1b..c72c79a27d3 100644 --- a/ansible/roles/eos/handlers/main.yml +++ b/ansible/roles/eos/handlers/main.yml @@ -1,3 +1,12 @@ - name: Restart the box command: /sbin/shutdown -r now "Ansible updates triggered" +- name: Pause for reboot + pause: seconds=30 + +- name: Wait for VM to come up + local_action: shell ansible -m ping -i veos {{ inventory_hostname }} + register: wait_result + until: wait_result.rc == 0 + retries: 30 + delay: 30 diff --git a/ansible/roles/eos/tasks/main.yml b/ansible/roles/eos/tasks/main.yml index c5ade3bdced..aaf0f5b1c31 100644 --- a/ansible/roles/eos/tasks/main.yml +++ b/ansible/roles/eos/tasks/main.yml @@ -53,6 +53,8 @@ - name: build a startup config template: src="{{ topo }}-{{ props.swrole }}.j2" dest=/mnt/flash/startup-config - when: configuration is defined + when: hostname in configuration notify: - Restart the box + - Pause for reboot + - Wait for VM to come up From 75604065831933ae7f1dfa5a52e0616468c6e31b Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 16 May 2019 15:03:57 +0800 Subject: [PATCH 2/4] [deploy] Replace handlers with tasks to ensure execution sequence --- ansible/roles/eos/tasks/main.yml | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ansible/roles/eos/tasks/main.yml b/ansible/roles/eos/tasks/main.yml index aaf0f5b1c31..e3c64d6f805 100644 --- a/ansible/roles/eos/tasks/main.yml +++ b/ansible/roles/eos/tasks/main.yml @@ -54,7 +54,21 @@ template: src="{{ topo }}-{{ props.swrole }}.j2" dest=/mnt/flash/startup-config when: hostname in configuration - notify: - - Restart the box - - Pause for reboot - - Wait for VM to come up + +- name: Restart the box + command: /sbin/shutdown -r now "Ansible updates triggered" + when: hostname in configuration + +- name: Pause for reboot + pause: seconds=30 + when: hostname in configuration + +- name: Wait for VM to come up + wait_for: + host: "{{ ansible_ssh_host }}" + port: 22 + state: started + delay: 10 + timeout: 600 + connection: local + when: hostname in configuration From 16994fd40c9c2ffe124fd34dcbe341da71fe6ce6 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Thu, 16 May 2019 15:04:37 +0800 Subject: [PATCH 3/4] [deploy] Replace ping cmd with wait_for module Signed-off-by: Xin Wang --- ansible/roles/eos/handlers/main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/ansible/roles/eos/handlers/main.yml b/ansible/roles/eos/handlers/main.yml index c72c79a27d3..2eb7a194606 100644 --- a/ansible/roles/eos/handlers/main.yml +++ b/ansible/roles/eos/handlers/main.yml @@ -5,8 +5,10 @@ pause: seconds=30 - name: Wait for VM to come up - local_action: shell ansible -m ping -i veos {{ inventory_hostname }} - register: wait_result - until: wait_result.rc == 0 - retries: 30 - delay: 30 + wait_for: + host: "{{ ansible_ssh_host }}" + port: 22 + state: started + delay: 30 + timeout: 900 + connection: local From cb7b4a099951933c3544e01b96c455b977061374 Mon Sep 17 00:00:00 2001 From: Xin Wang Date: Fri, 17 May 2019 09:14:18 +0800 Subject: [PATCH 4/4] [deploy] Remove unused handlers Signed-off-by: Xin Wang --- ansible/roles/eos/handlers/main.yml | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 ansible/roles/eos/handlers/main.yml diff --git a/ansible/roles/eos/handlers/main.yml b/ansible/roles/eos/handlers/main.yml deleted file mode 100644 index 2eb7a194606..00000000000 --- a/ansible/roles/eos/handlers/main.yml +++ /dev/null @@ -1,14 +0,0 @@ -- name: Restart the box - command: /sbin/shutdown -r now "Ansible updates triggered" - -- name: Pause for reboot - pause: seconds=30 - -- name: Wait for VM to come up - wait_for: - host: "{{ ansible_ssh_host }}" - port: 22 - state: started - delay: 30 - timeout: 900 - connection: local