Skip to content
Merged
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
36 changes: 30 additions & 6 deletions ansible/roles/test/tasks/advanced-reboot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,29 @@
dest: /tmp/ports.json
delegate_to: "{{ ptf_host }}"

- debug: msg="Defined new sonic image url is {{ new_sonic_image }}"
when: new_sonic_image is defined

- set_fact:
stay_in_target_image: "{{ stay_in_target_image | default('false') | bool }}"
cleanup_old_sonic_images: "{{ cleanup_old_sonic_images | default('false') | bool }}"

- block:

- name: Save image version
shell: 'sonic_installer list | grep Current | cut -f2 -d " "'
register: current_sonic_image
become: true
when: not stay_in_target_image

- name: Generate temp file name on target device
shell: mktemp
register: tempfile

- set_fact:
new_image_location: '/tmp/new_sonic_image.bin'
new_image_location: '{{ tempfile.stdout }}'

- debug: msg='Setting image file name to {{ new_image_location }}'

- name: Download SONiC image.
local_action: get_url url={{ new_sonic_image }} dest={{ new_image_location }}
Expand All @@ -124,14 +138,24 @@
src: "{{ new_image_location }}"
dest: "{{ new_image_location }}"

- name: Install a new SONiC image if requested
shell: sonic_installer install -y {{ new_image_location }}
- name: Cleanup sonic images that is not current and/or next
shell: sonic_installer cleanup -y
become: true
when: cleanup_old_sonic_images

- name: 'Setup restoring initial image {{ current_sonic_image }}'
shell: /bin/true
connection: local
notify:
- restore current image
- reboot sonic
- restore current image
- reboot sonic
when: not stay_in_target_image

when: new_sonic_image is defined
- name: Installing new SONiC image
shell: sonic_installer install -y {{ new_image_location }}
become: true

when: new_sonic_image | default('') | length > 0

- include: ptf_runner.yml
vars:
Expand Down