ftntcorecse / fndn_ansible

DEPRECATED - See New Ansible Galaxy Collections: https://galaxy.ansible.com/fortinet
https://galaxy.ansible.com/fortinet
17 stars 5 forks source link

"The data is invalid for selected url" #9

Open Remey opened 4 years ago

Remey commented 4 years ago

Hi,

I have been trying to configure AWX to use Ansible to add changes to our FortiManager.

At the moment I have managed to get fmgr_query (https://ftnt-ansible-docs.readthedocs.io/en/latest/fmgr_modules/fmgr_query.html) to work and return a result.

I am now trying to get fmgr_fwobj_address (https://ftnt-ansible-docs.readthedocs.io/en/latest/fmgr_modules/fmgr_fwobj_address.html) to work but not having much luck, I keep receiving the following error:

{ "msg": "The data is invalid for selected url", "changed": false, "unreachable": false, "ansible_facts": { "response": [ -10, { "status": { "code": -10, "message": "The data is invalid for selected url" }, "url": "/pm/config/adom/root/obj/firewall/address" } ], "ansible_params": { "ipv4": "ipmask", "ipv4addr": "1.2.3.4/32", "name": "AWX_TEST", "comment": "Test", "color": "1", "visibility": "enable", "adom": "root", "mode": "add", "allow_routing": "disable" }, "paramgram": { "adom": "root", "allow-routing": "disable", "color": "1", "comment": "Test", "name": "AWX_TEST", "visibility": "enable", "ipv4": "ipmask", "ipv4addr": "1.2.3.4/32", "mode": "add" }, "connected_fmgr": { "Admin Domain Configuration": "Enabled", "BIOS version": "04000002", "Branch Point": "0429", "Build": "0429", "Current Time": "Mon Feb 03 17:49:04 GMT 2020", "Daylight Time Saving": "Yes", "FIPS Mode": "Disabled", "HA Mode": "HA Master", "Hostname": "opfwmgmt01b", "License Status": "Valid", "Major": 6, "Max Number of Admin Domains": 200, "Max Number of Device Groups": 200, "Minor": 0, "Offline Mode": "Disabled", "Patch": 8, "Platform Full Name": "FortiManager-VM64", "Platform Type": "FMG-VM64", "Release Version Information": " (GA)", "Serial Number": "FMG-VM0A14003861", "Time Zone": "(GMT) London, Edinburgh.", "Version": "v6.0.8-build0429 200121 (GA)", "x86-64 Applications": "Yes" }, "discovered_interpreter_python": "/usr/libexec/platform-python" }, "rc": -10, "invocation": { "module_args": { "ipv4": "ipmask", "ipv4addr": "1.2.3.4/32", "name": "AWX_TEST", "comment": "Test", "color": "1", "visibility": "enable", "adom": "root", "mode": "add", "allow_routing": "disable" } }, "ansible_module_results": { "status": { "code": -10, "message": "The data is invalid for selected url" }, "url": "/pm/config/adom/root/obj/firewall/address" }, "_ansible_no_log": false }

Old (Created by us) { "cache": 1, "client": "gui json:27394", "id": 1, "method": "add", "params": [{ "data": { "associated-interface": "any", "cache-ttl": 0, "color": 0, "comment": "Test", "country": null, "dynamic_mapping": null, "end-ip": "0.0.0.0", "meta fields": {}, "name": "Remey_Test", "start-ip": "0.0.0.0", "subnet": ["1.2.3.4", "255.255.255.255"], "tags": null, "type": 0, "uuid": "00000000-0000-0000-0000-000000000000", "visibility": 1, "wildcard": null}, "url": "pm\/config\/adom\/root\/obj\/firewall\/address"}], "session": 14207}
New (From: https://ftnt-ansible-docs.readthedocs.io/en/latest/fmgr_modules.html ) { "client": "\/usr\/local\/apache2\/bin\/httpd:15971", "id": 4, "method": "add", "params": [{ "data": { "allow-routing": "disable", "associated-interface": null, "cache-ttl": null, "color": "1", "comment": "Test", "dynamic_mapping": [], "meta fields": {}, "name": "AWX_TEST", "subnet": ["1.2.3.4", "255.255.255.255"], "type": "ipmask", "visibility": "disable"}, "url": "\/pm\/config\/adom\/root\/obj\/firewall\/address"}], "session": "9XwGFUyMjKysRWJ+CpnQHKmK9t2XWEcB\/FdG\/1jTa0nxAdktzU3fc4\/Rm7PMYRryXSEQ3wy5cek7lnVTrS28ag==", "src": "10.5.50.4", "verbose": 1}

I have noticed that the main difference is in the Old one the type is 0 ("type": 0). On the New one the type is ipmask ("type": "ipmask”). I am not to sure why this is or how to allow FortiManager to accept (ipmask).

Would you know how best to troubleshoot this or be able to help us figure out this problem?

If you need any more info please let me know.

  1. Python version?

python3.6

  1. Ansible version?

Ansible 2.8.5 AWX 9.0.1.0

Many Thanks, Remey

prabowoekky commented 2 years ago

no update for this issue ??

4driano commented 2 years ago

Hi, I had the same issue once that FortiManager has been upgrated up to version 6.4.7. The are both differences within the json structure (e.g. data is not an array anymore) and within some fields (e.g. subnet is not anymore just a string, but an array). Here is the payload that now works for me:

payload = { "id": 1, "method": "add", "params": [ { "url": "put_here_your_url", "data": { "subnet": [ "put_here_your_ipv4", "255.255.255.255" ], "type": 0, "associated-interface": [ "any" ], "allow-routing": 0, "cache-ttl": 0, "clearpass-spt": 0, "color": 0, "comment": "string", "name": "string", } } ], "session": self.session }