Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion ansible/roles/eos/files/boot-config
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
SWI=flash:/vEOS.swi

20 changes: 20 additions & 0 deletions ansible/roles/eos/handlers/common_handlers/update_state.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
- name: Reboot the VM
command: /sbin/shutdown -r now "Ansible updates triggered"

- name: Wait for VM to shutdown
wait_for:
host: "{{ ansible_ssh_host }}"
port: 22
state: stopped
delay: 10
timeout: 300
connection: local

- name: Wait for VM to startup
wait_for:
host: "{{ ansible_ssh_host }}"
port: 22
state: started
delay: 10
timeout: 1200
connection: local
5 changes: 5 additions & 0 deletions ansible/roles/eos/handlers/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Notify handlers are always run in the same order they are defined, not in the order listed in the notify-statement.
# This is also the case for handlers using listen.

- name: Update VM state
include: roles/eos/handlers/common_handlers/update_state.yml
33 changes: 10 additions & 23 deletions ansible/roles/eos/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,34 +41,21 @@
set_fact: properties_list="{{ configuration[hostname]['properties'] }}"
when: configuration and configuration[hostname] and configuration[hostname]['properties'] is defined

- name: copy boot-config
copy: src=boot-config
dest=/mnt/flash/boot-config

- name: Expand {{ hostname }} properties into props
set_fact: props="{{ configuration_properties[item] | combine(props | default({})) }}"
with_items: properties_list
when: hostname in configuration and configuration_properties[item] is defined

- name: build a startup config
template: src="{{ topo }}-{{ props.swrole }}.j2"
dest=/mnt/flash/startup-config
when: hostname in configuration

- name: Restart the box
command: /sbin/shutdown -r now "Ansible updates triggered"
when: hostname in configuration

- name: Pause for reboot
pause: seconds=30
- name: copy boot-config
copy: src=boot-config
dest=/mnt/flash/boot-config
when: hostname in configuration
notify:
- Update VM state

- name: Wait for VM to come up
wait_for:
host: "{{ ansible_ssh_host }}"
port: 22
state: started
delay: 10
timeout: 600
connection: local
- name: update startup-config
template: src="{{ topo }}-{{ props.swrole }}.j2"
dest=/mnt/flash/startup-config
when: hostname in configuration
notify:
- Update VM state