Meraki automation with Ansible playbook question..

antienhe
Just browsing

Meraki automation with Ansible playbook question..

try to enable routing using VLAN using the ansible playbook. The ansible give the http request: Enable/Disable VLANs for the given network HTTP REQUEST PUT/networks/{networkId}/vlansEnabledState But how to convert it into ansible-play book? I tried curl, playbook format all failed. But postman does work. Ansible: I will get 404 error. "msg": "Status code was 404 and not [200]: HTTP Error 404: Not Found", is the body part of the code correct? - name: enable routing use VLAN. uri: url: https://api.meraki.com/api/v0/networks/{{var_net_name}}/vlansEnabledState method: PUT auth_key: "{{var_auth_key}}" org_id: "{{var_org_id}}" net_id: "{{var_net_name}}" body: enabled: "true" body_format: json headers: Content-Type: "application/json" Thanks Antien
6 Replies 6
jdsilva
Kind of a big deal

404's are usually an incorrect API key. Does your key have write privs? And is it correct?

 

The other thing I see that I'm not sure (Ansible is still on my ToLearn list) is that the enabled: "true" should be a bool, not a string. Does Ansible properly convert that? Or should it read enabled: True instead?

Hi jdsila,

 

Thanks for reply.

Yes the API key is correct. I use it in postman and ansible other playbooks. this is one of the feature that does not come from the ansbile existing module.

Ansible did offer convert curl into uri module. I follow it and failed. 😞

Just tried it and get same error.

This time, I will post the whole error message. 

I don't think it is the " but not sure... if any one know ansible may help?


Antien

 

fatal: [api.meraki.com]: FAILED! => {
"cache_control": "no-cache",
"changed": false,
"connection": "close",
"content": " ",
"content_type": "text/html; charset=utf-8",
"date": "Tue, 30 Jul 2019 19:45:37 GMT",
"elapsed": 0,
"invocation": {
"module_args": {
"attributes": null,
"auth_key": """my key}}",
"backup": null,
"body": {
"enabled": true
},
"body_format": "json",
"client_cert": null,
"client_key": null,
"content": null,
"creates": null,
"delimiter": null,
"dest": null,
"directory_mode": null,
"follow": false,
"follow_redirects": "safe",
"force": false,
"force_basic_auth": false,
"group": null,
"headers": {
"Content-Type": "application/json"
},
"http_agent": "ansible-httpget",
"method": "PUT",
"mode": null,
"net_id": "{{netid}}",
"org_id": 370177,
"owner": null,
"regexp": null,
"remote_src": null,
"removes": null,
"return_content": false,
"selevel": null,
"serole": null,
"setype": null,
"seuser": null,
"src": null,
"status_code": [
200
],
"timeout": 30,
"unix_socket": null,
"unsafe_writes": null,
"url": "https://api.meraki.com/api/v0/networks/{{netid}}/vlansEnabledState",
"url_password": null,
"url_username": null,
"use_proxy": true,
"validate_certs": true
}
},
"msg": "Status code was 404 and not [200]: HTTP Error 404: Not Found",
"redirected": false,
"server": "nginx",
"status": 404,
"transfer_encoding": "chunked",
"url": "https://api.meraki.com/api/v0/networks/{{netid}}/vlansEnabledState",
"vary": "Accept-Encoding",
"x_request_id": "4fa13837f83d4303926fa94ab4910bba",
"x_runtime": "0.025126",
"x_ua_compatible": "IE=Edge,chrome=1"
}

PLAY RECAP ************************************************************************************************************************************************************
api.meraki.com : ok=1 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0

 

The strange part is that there is a 200 respond on the http_agent session. so I am assuming the code is in dashboard and correct.

But after 30 time out the respond become 404.

 

I also disable the "validate_certs": true ti false. it still the same error.


Antien

PhilipDAth
Kind of a big deal
Kind of a big deal

When you make a request to https://api.meraki.com/ it actually redirects you to your "shard".

 

Make sure Ansible is set to follow HTTP 302 redirect messages.

Raj66
Meraki Employee
Meraki Employee

@antienhe  Just a safety precaution, please make sure to mask out sensitive information like API key or network IDs in the public forum for security purpose. This information is sensitive and can easily be misused.

 

Cheers!

 

Raj

If you found this post helpful, please give it kudos. If my answer solved your problem, click "accept as solution" so that others can benefit from it
RayD
Just browsing

 Did you ever figure this out...i'm having the same problem.  My api key works fine when using the meraki modules, but using the uri module i get the 404...

Get notified when there are additional replies to this discussion.
Welcome to the Meraki Community!
To start contributing, simply sign in with your Cisco account. If you don't yet have a Cisco account, you can sign up.