fortinet / ansible-fortimanager-generic

8 stars 6 forks source link

Added more code to check params and url #4

Closed chillancezen closed 4 years ago

chillancezen commented 4 years ago

This patch checks parameters and url.

params must be an array.

otherwise, it reports errors like:

fatal: [fortimanager01]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "json": "{\n \"method\":\"set\",\n \"params\": \n  {\n       \"url\":\"/dvmdb/adom/root/script\",\n       \"data\":[\n          {\n             \"name\": \"user_script2\",\n             \"type\": \"cli\",\n             \"desc\": \"The script is created by ansible\",\n             \"content\": \"the script content to be executed\"\n          }\n        ]\n   }\n \n}\n",
            "method": null,
            "params": null
        }
    },
    "msg": "parameter:params must be an array"
}

PLAY RECAP ***************************************************************************************************************************************************************************************************************
fortimanager01             : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0

url must be in a parameter block.

otherwise, it reports errors like:

fatal: [fortimanager01]: FAILED! => {
    "changed": false,
    "invocation": {
        "module_args": {
            "json": "{\n \"method\":\"set\",\n \"params\":[ \n  {\n       \"data\":[\n          {\n             \"name\": \"user_script2\",\n             \"type\": \"cli\",\n             \"desc\": \"The script is created by ansible\",\n             \"content\": \"the script content to be executed\"\n          }\n        ]\n   }\n ]\n}\n",
            "method": null,
            "params": null
        }
    },
    "msg": "url must be specified in params"
}

PLAY RECAP ***************************************************************************************************************************************************************************************************************
fortimanager01             : ok=1    changed=0    unreachable=0    failed=1    skipped=0    rescued=0    ignored=0