---
- name: validate required connection is configured
  fail:
    msg: "expected connection value to be set to network_cli, got {{ ansible_connection }}"
  when: ansible_connection != 'network_cli'

- name: Validate subset var is a list
  fail:
    msg: "subset must be in the form a list, not string"
  when: subset is defined and subset is string

- name: collect platform capabilities as facts
  ios_capabilities:

- name: run command and parse output
  include_tasks: includes/run_cli.yaml
  vars:
    ios_command: "{{ item.command }}"
    ios_parser: "cli/{{ item.parser }}"
    ios_parser_engine: "{{ item.engine | default('command_parser') }}"
    ios_name: "{{ item.name | default(None) }}"
    ios_run_cli_command_pre_hook: "{{ item.pre_hook | default(None) }}"
    ios_run_cli_command_post_hook: "{{ item.post_hook | default(None) }}"
  loop: "{{ lookup('file', ios_get_facts_command_map) | from_yaml }}"
  when: ios_get_facts_subset |  intersect(item.groups)
