@Peter Sprygada: I'm now facing a more complicated case where I have trouble accessing stdout[0]:
- name: Fetching PACL_Table on all L2 interfaces from the remote node
ios_command:
provider: "{{ connections.ssh }}"
commands:
- "show run interface {{ net_item.key }} | include ^interface|access-group"
with_dict: "{{ ansible_net_interfaces }}"
when: net_item.value.ipv4.address is not defined
loop_control:
loop_var: net_item
register: pacl_tables
- name: Printing pacl_tables.results
debug: var=pacl_tables.results
ok: [IOSv_L2_10] => {
"pacl_tables.results": [
{
"_ansible_item_label": {
"key": "GigabitEthernet1/2",
"value": {
"bandwidth": 1000000,
"duplex": "Full",
"ipv4": null,
"lineprotocol": "up (connected) ",
"macaddress": "0036.2586.7e06",
"mediatype": "unknown media type",
"mtu": 1500,
"operstatus": "up",
"type": "iGbE"
}
},
"_ansible_item_result": true,
"_ansible_no_log": false,
"_ansible_parsed": true,
"changed": false,
"invocation": {
"module_args": {
"auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"authorize": true,
"commands": [
"show run interface GigabitEthernet1/2 | include ^interface|access-group"
],
"host": "172.21.100.210",
"interval": 1,
"match": "all",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"provider": {
"auth_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"authorize": true,
"host": "172.21.100.210",
"password": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
"port": 22,
"ssh_keyfile": "~/.ssh/id_rsa",
"timeout": 10,
"transport": "cli",
"username": "admin",
"version": 2
},
"retries": 10,
"ssh_keyfile": "/root/.ssh/id_rsa",
"timeout": 10,
"transport": "cli",
"use_ssl": true,
"username": "admin",
"validate_certs": true,
"wait_for": null
},
"module_name": "ios_command"
},
"net_item": {
"key": "GigabitEthernet1/2",
"value": {
"bandwidth": 1000000,
"duplex": "Full",
"ipv4": null,
"lineprotocol": "up (connected) ",
"macaddress": "0036.2586.7e06",
"mediatype": "unknown media type",
"mtu": 1500,
"operstatus": "up",
"type": "iGbE"
}
},
"stdout": [
"show run interface GigabitEthernet1/2 | include ^interface|access-$terface GigabitEthernet1/2 | include ^interface|access-g oup\ninterface GigabitEthernet1/2"
],
"stdout_lines": [
[
"show run interface GigabitEthernet1/2 | include ^interface|access-$terface GigabitEthernet1/2 | include ^interface|access-g oup",
"interface GigabitEthernet1/2"
]
],
"warnings": []
},
...repeated n times, for all found L2 interfaces.
How can we correctly access a table of results? (I'm not mentioning the issue with the strange result itself.)