---
- name: "Run command and parse with {{ parser }}"
  ansible.utils.cli_parse:
    command: "show interface"
    parser:
      name: ansible.netcommon.native
    set_fact: POpqMQoJWTiDpEW
  register: nxos_native_command

- name: "Pass text and template_path to {{ parser }}"
  ansible.utils.cli_parse:
    text: "{{ nxos_native_command['stdout'] }}"
    parser:
      name: ansible.netcommon.native
      template_path: "{{ role_path }}/templates/nxos_show_interface.yaml"
  register: nxos_native_text

- name: "Check output"
  ansible.builtin.assert:
    that: "{{ item }}"
  with_items:
    - "{{ POpqMQoJWTiDpEW is defined }}"
    - "{{ nxos_native_command['parsed']['mgmt0'] is defined }}"
    - "{{ nxos_native_command['stdout'] is defined }}"
    - "{{ nxos_native_command['stdout_lines'] is defined }}"
    - "{{ nxos_native_command['parsed'] == nxos_native_text['parsed'] }}"

- name: "Pass text and command to {{ parser }}"
  ansible.utils.cli_parse:
    text: "{{ nxos_native_command['stdout'] }}"
    parser:
      name: ansible.netcommon.native
      command: show interface
  register: output

- name: "Check output"
  ansible.builtin.assert:
    that: "{{ item }}"
  with_items:
    - "{{ output['parsed']['mgmt0'] is defined }}"

- name: "Run command and parse with {{ parser }}"
  ansible.utils.cli_parse:
    command: "sho int"
    parser:
      name: ansible.netcommon.native
      command: show interface
  register: output

- name: "Check output"
  ansible.builtin.assert:
    that: "{{ item }}"
  with_items:
    - "{{ output['parsed']['mgmt0'] is defined }}"
    - "{{ output['stdout'] is defined }}"
    - "{{ output['stdout_lines'] is defined }}"
