Open ryanmerolle opened 3 years ago
@ryanmerolle Please add wait_for_connection
task in between the RELOAD DEVICE
and RESET CONNECTION
tasks. wait_for_connection
waits until the device is in usable state and then proceeds with the following tasks.
Interesting.
I will test this shortly. Does that mean the article is wrong:
- reboot task (this is a snippet, full task removed for brevity)
- name: reset the connection
meta: reset_connection
- name: Wait for the network device to reload
wait_for_connection:
delay: 10
Hi @ryanmerolle: This is what worked for me:
- name: Reload Device
arista.eos.eos_command:
commands: reload now
ignore_errors: True
- name: Wait for the connection
wait_for:
host: '{{ (ansible_ssh_host|default(ansible_host))|default(inventory_hostname) }}'
port: 22
- name: reset the connection (OR replace this with any other following tasks to be done after reload)
meta: reset_connection
Putting ignore_errors will ignore the error from reload command disconnection, and next task can wait for the connection to the device to be available again.
@GomathiselviS I wrote the blog here, can you clarify?
@IPvSean From what I tested on a local vm, once we give reload now command, it takes a few seconds to actually start rebooting. The reset connection task gets executed even before the device starts to reboot. That is why the reset_connection task needs to go after wait_for_connection.
I am able to reboot a cisco ios network device with this->
- name: reboot machine
cisco.ios.ios_command:
commands:
- command: 'reload'
prompt:
- Proceed
answer:
- "y"
- name: Wait for the network device to reload
wait_for:
host: "{{ ansible_host }}"
delay: 40
timeout: 600
port: 22
vars:
ansible_connection: local
I will do some more testing... but this seems to work consistently, it takes like 5 minutes for IOS to reboot and it gets it
SUMMARY
Per Rebooting Network Devices with Ansible @ipvsean mentions that the following should not fail the reboot task.
Yet when I set these 2 tasks to end my play, the task errors out.
@ipvsean suggested I open an issue on this.
ISSUE TYPE
COMPONENT NAME
arista.eos.commands
ANSIBLE VERSION
CONFIGURATION
OS / ENVIRONMENT
Ubuntu 20.04 Arista EOS 4.25.4M
STEPS TO REPRODUCE
EXPECTED RESULTS
The task should not fail because of the rebooting device & ansible timeout
ACTUAL RESULTS
The task fails.