@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

...leads to:
ok: [IOSv_L2_10] => {
    "pacl_tables.results": [
        {
            "_ansible_item_label": {
                "key": "GigabitEthernet1/2", 
                "value": {
                    "bandwidth": 1000000, 
                    "description": "Connected to 
[u'IOSv_Leaf_16.actionmystique.net'] on its port [u'Gi0/0']", 
                    "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, 
                    "description": "Connected to 
[u'IOSv_Leaf_16.actionmystique.net'] on its port [u'Gi0/0']", 
                    "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.

However, I cannot access stdout[0] for all these interfaces with:
- name: Printing pacl_tables.results.stdout
  debug: var=print_item.stdout[0]
  with_dict: "{{ pacl_tables.results }}"
  loop_control:
    loop_var: print_item
... which leads to:
fatal: [IOSv_L2_10]: FAILED! => {"failed": true, "msg": "with_dict expects 
a dict"}

How can we correctly access a table of results? (I'm not mentioning the 
issue with the strange result itself.)

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/1a3de0c3-cdfc-45a7-81c2-cff93b6a89d3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to