---
- debug: msg="START connection={{ ansible_connection }}/set_state_present.yaml"
- debug: msg="Using provider={{ connection.transport }}"
  when: ansible_connection == "local"

- name: setup
  nxos_config:
    lines:
      - no interface Loopback1
  ignore_errors: yes # Fails if the interface is already absent

- name: set state=present
  nxos_interface:
    interface: Loopback1
    state: present
    description: 'Configured by Ansible - Layer3'
  register: result

- assert:
    that:
      - "result.changed == true"

- name: verify state=present
  nxos_interface:
    interface: Loopback1
    state: present
    description: 'Configured by Ansible - Layer3'
  register: result

- assert:
    that:
      - "result.changed == false"

- debug: msg="END connection={{ ansible_connection }}/set_state_present.yaml"
