---
- name: "Install OS image {{ si }} using provider"
  check_mode: "{{ checkmode }}"
  nxos_install_os:
    system_image_file: "{{ si }}"
    kickstart_image_file: "{{ ki }}"
    issu: "{{ issu }}"
    provider: "{{ connection }}"
  register: result

- debug: msg=" {{ result['install_state'] }}"

- name: Wait for device to come back up with new image
  wait_for:
    port: 22
    state: started
    timeout: 500
    delay: 60
    host: "{{ inventory_hostname }}"
  when: result.changed and not checkmode

- debug: msg='Wait 5 mins to allow system to stabilize'
  when: result.changed and not checkmode
- pause:
    seconds: 300
  when: result.changed and not checkmode
