Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

meraki_device making wrong API call #463

Open
victoreebel opened this issue Aug 12, 2023 · 7 comments
Open

meraki_device making wrong API call #463

victoreebel opened this issue Aug 12, 2023 · 7 comments
Assignees

Comments

@victoreebel
Copy link

victoreebel commented Aug 12, 2023

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

@kbreit kbreit self-assigned this Aug 15, 2023
@kbreit
Copy link
Collaborator

kbreit commented Aug 15, 2023

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.

@kbreit
Copy link
Collaborator

kbreit commented Aug 15, 2023

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.

@kbreit
Copy link
Collaborator

kbreit commented Aug 16, 2023

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.

@victoreebel
Copy link
Author

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.

@kbreit
Copy link
Collaborator

kbreit commented Aug 22, 2023

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

templates = self.get_config_templates(org_id)
. 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?

@victoreebel
Copy link
Author

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.

@kbreit
Copy link
Collaborator

kbreit commented Aug 29, 2023

Can you try testing /organizations/{organizationId}/configTemplates? I want to see what happens with that. Also, please try commenting out

templates = self.get_config_templates(org_id)
for t in templates:
self.nets.append(t)
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants