---
- set_fact: ignore_errors_httpapi='no'
- set_fact: ignore_errors_httpapi='yes'
  when: ansible_connection == 'httpapi'

- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server.yaml
  when: connection is not defined

- include: targets/nxos_install_os/tasks/upgrade/enable_scp_server_provider.yaml
  when: connection is defined

- name: "Copy {{ si }} to bootflash"
  nxos_file_copy:
    local_file: "{{image_dir}}{{ si }}"
    file_system: "bootflash:"
  register: result
  ignore_errors: "{{ ignore_errors_httpapi }}"

- name: "Copy {{ si }} to bootflash"
  nxos_file_copy:
    local_file: "{{image_dir}}{{ si }}"
    file_system: "bootflash:"
  register: result
  ignore_errors: "{{ ignore_errors_httpapi }}"

- debug:
    msg: "{{ item.key }} {{ item.value }}"
  with_dict: "{{ result }}"

- name: "Copy {{ ki }} to bootflash"
  nxos_file_copy:
    local_file: "{{image_dir}}/{{ ki }}"
    file_system: "bootflash:"
  register: result
  when: ki is defined
  ignore_errors: "{{ ignore_errors_httpapi }}"

- debug:
    msg: "{{ item.key }} {{ item.value }}"
  with_dict: "{{ result }}"
  when: ki is defined
