CiscoDevNet/ansible-meraki

meraki_network query by ID returns empty data object

mystery-rabbit opened this issue · 1 comments

Where a valid network exists, the following:

  - name: Query one network by ID
    meraki_network:
      auth_key: '{{ auth_key }}'
      state: query
      org_name: '{{test_org_name}}'
      net_id: "{{ net_id}}"
    delegate_to: localhost
    register: net_query_one_id

returns:

TASK [meraki_network : Query one network by ID - debug] ************************
ok: [localhost] => {
    "net_query_one_id": {
        "changed": false,
        "data": false,
        "failed": false,
        "response": "OK (unknown bytes)",
        "status": 200
    }
}

having looked in the code, meraki_network only queries using "net_name". Lines 361-364:

meraki.result["data"] = meraki.get_net(
                    meraki.params["org_name"], meraki.params["net_name"], data=nets
                )

one answer is to modify that to add net_id to the call the meraki.get since there are protections in the code already against them both being set:

 meraki.result["data"] = meraki.get_net(
                    meraki.params["org_name"], net_name=meraki.params["net_name"], data=nets, net_id=meraki.params["net_id"],
                )

I've run a POC for the above and it seems to resolve the issue - happy to submit a PR if you would like.

kbreit commented

Yes please submit a PR. Looks like the change is relatively straight forward.