Last active
July 31, 2023 18:46
-
-
Save IPvSean/56f6522cc73629984d3e47013240a1fa to your computer and use it in GitHub Desktop.
Reboot Ansible Playbook for an Arista vEOS machine
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reboot an Arista EOS switch | |
--- | |
- name: Reboot arista eos switch | |
hosts: routers | |
gather_facts: false | |
tasks: | |
- name: Reboot device | |
ansible.netcommon.cli_command: | |
command: reload now | |
- name: Reset the connection | |
ansible.builtin.meta: reset_connection | |
- name: Wait for network device to come back up | |
ansible.builtin.wait_for_connection: | |
delay: 10 | |
- name: Retrieve the uptime | |
ansible.netcommon.cli_command: | |
command: show ver | i Uptime | |
register: uptime | |
- name: Show uptime | |
ansible.builtin.debug: | |
msg: "{{ uptime.stdout }}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[student1@ansible ~]$ ansible-playbook arista.yml | |
PLAY [reboot arista eos router] *************************************************************************************************************************************************** | |
TASK [reboot device] ************************************************************************************************************************************************************* | |
ok: [rtr1] | |
ok: [rtr3] | |
ok: [rtr4] | |
ok: [rtr2] | |
TASK [wait for network device to come back up] ************************************************************************************************************************************* | |
ok: [rtr2] | |
ok: [rtr1] | |
ok: [rtr4] | |
ok: [rtr3] | |
TASK [grab the uptime] *********************************************************************************************************************************************************** | |
ok: [rtr1] | |
ok: [rtr4] | |
ok: [rtr3] | |
ok: [rtr2] | |
TASK [show uptime] *************************************************************************************************************************************************************** | |
ok: [rtr2] => | |
msg: 'Uptime: 0 weeks, 0 days, 0 hours and 2 minutes' | |
ok: [rtr3] => | |
msg: 'Uptime: 0 weeks, 0 days, 0 hours and 2 minutes' | |
ok: [rtr4] => | |
msg: 'Uptime: 0 weeks, 0 days, 0 hours and 2 minutes' | |
ok: [rtr1] => | |
msg: 'Uptime: 0 weeks, 0 days, 0 hours and 2 minutes' | |
PLAY RECAP *********************************************************************************************************************************************************************** | |
rtr1 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 | |
rtr2 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 | |
rtr3 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 | |
rtr4 : ok=4 changed=0 unreachable=0 failed=0 skipped=0 rescued=0 ignored=0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment