CiscoDevNet / FMCAnsible

GNU General Public License v3.0
21 stars 25 forks source link

Creating host objects doesn't appear to work? #55

Closed ibplayn closed 1 year ago

ibplayn commented 1 year ago

Has anyone successfully created host objects with this repo? I cannot seem to get creating host objects to work. FMC version 7.2.4 Playbook:

---
- name: Firepower - Create Host Object
   hosts: firepower
   connection: httpapi
   tasks:
      - name: Get Domain UUID
         cisco.fmcansible.fmc_configuration:
            operation: getAllDomain
            register_as: domain

      - name: Create Network Object
         cisco.fmcansible.fmc_configuration:
             operation: createMultipleNetworkObject
             data:
              - name: "testhostname"
                value: "10.10.10.10"
                type: Host
              path_params:
                 domainUUID: '{{ domain[0].uuid }}'

Error: fatal: [firewall.example.com]: FAILED! => {"changed": false, "msg": "Server returned an error trying to execute createMultipleNetwork operation. Status code: 400. Server Response: Input type mismatch. You have entered an invalid value 10.10.10.10 for selected type Network."}

Perhaps I am not specifying the correct type, or using the wrong syntax but I have tried multiple variations with no success.

xibriz commented 1 year ago

@ibplayn createMultipleNetworkObject is for Network objects.

I use operation upsertHostObject for Host objects and upsertNetworkObject for Network objects.

ibplayn commented 1 year ago

Thank you @xibriz! It would be nice if these were documented better outside of the FMC itself. I used another issue (#15) to figure out where these were 'defined' in the API. I am opening another issue as now, these two operations (and who know how many others) are not idempotent. Example error from re-using the same object name: fatal: [firewall.example.com]: FAILED! => {"changed": false, "msg": "Server returned an error trying to execute createMultipleHostObject operation. Status code: 400. Server response: The object name testansible02 already exists. Enter a new name."}

fatal: [firewall.example.com]: FAILED! => {"changed": false, "msg": "Server returned an error trying to execute upsertHostObject operation. Status code: 400. Server response: The object name testansible02 already exists. Enter a new name."}

xibriz commented 1 year ago

@ibplayn I have downloaded the JSON-spec you get when you navigate to /api/api-explorer/ and click "Download Spec" in the upper right corner. Then you can easily find the correct operation (operationId) for each API-call you want do make :)