ansible-meraki
ansible-meraki copied to clipboard
meraki_device making wrong API call
Trying the first example from the doc 'query all devices', substituting the dummy values for my own:
- name: Query all devices in a network.
cisco.meraki.meraki_device:
auth_key: MYKEY
org_name: MYORG
net_name: MYNET
state: query
delegate_to: localhost
Might be missing something, but I'm getting this return -
"msg": 404,
"response": "OK (unknown bytes)",
"status": 404,
"url": "https://api.meraki.com/api/v1/organizations/<MY ORG ID>/configTemplates"
So it doesn't seem to be hitting the devices API, rather the configTemplates one.
Module version is 2.15.3
Thank you for reporting this. It's quite an interesting bug as well. I do store some URLs in the shared code between modules but I can't tell why that particular URL is called. Give me a little time to look into this.
I think I've identified why it's failing. Can you try to use net_id instead of net_name? I expect it will work. If it does work, please let me know if your organization has any config templates.
My theory was if an organization had no configuration templates it would give a 404 but that's not the case. Unfortunately, I can't reproduce the bug. Can you describe your organization/network environment in some detail, especially around the configuration templates, so I can see if I can reproduce it? Thank you.
Thanks for this - I've tried using every combination of org_name, org_id, net_name and net_id with two networks, but get the same response in all cases (the org string being passed to the config_templates call).
I also encountered a similar issue with the ACLs module, and in that case was actually able to get that to work by using the net_id rather than net_name, interestingly.
The org in question is currently in the process of being handed over to us, so don't have full visibility r.e. configuration templates, but will try to find out.
Thank you. Let me know what you find out. I haven't been able to reproduce it but I think I see where it's happening. When the module downloads all the networks it also downloads all the configuration templates at https://github.com/CiscoDevNet/ansible-meraki/blob/6456adf4f82dcb7931054bf411a270014f5baaf4/plugins/module_utils/network/meraki/meraki.py#L267. Eventually that makes a call to my request()
method and if it has an error code above 400, it errors https://github.com/CiscoDevNet/ansible-meraki/blob/6456adf4f82dcb7931054bf411a270014f5baaf4/plugins/module_utils/network/meraki/meraki.py#L436C13-L436C13.
By chance, do you have access to an API tool like Postman to do some testing to see how we can get that to work?
Thanks for looking into this. Just heard from the other team, they confirmed that no configuration templates are currently in use.
Also tried omitting both net_id and net_name from the play (so ommitting network altogether) and just using org_name, and still hitting the same error.
I also encountered a similar issue with the ACLs module, and in that case was actually able to get that to work by using the net_id rather than net_name, interestingly.
This I've now noticed with several modules, but in all other cases except the meraki_device one, using net_id prevents the issue from happening.
The organization currently consists of 3 distinct networks - an appliance one, switched and wireless and a combined one.
I do have Postman setup. Which tests did you have in mind? Right off the bat I can say that running {{baseUrl}}/organizations/:organizationId/devices returns succesfully.
Can you try testing /organizations/{organizationId}/configTemplates
? I want to see what happens with that. Also, please try commenting out https://github.com/CiscoDevNet/ansible-meraki/blob/6456adf4f82dcb7931054bf411a270014f5baaf4/plugins/module_utils/network/meraki/meraki.py#L267-L269 from the file specified in the link. That's where I think it's doing the lookup so if commenting out that code fixes the problem, it at least isolates it.