CiscoDevNet / FMCAnsible

GNU General Public License v3.0
20 stars 24 forks source link

Create NAT Policy #57

Open xibriz opened 1 year ago

xibriz commented 1 year ago

In our FMC, we have 25 NAT Policies.

When trying to create a new policy using the following task:

- name: Create NAT policy
  cisco.fmcansible.fmc_configuration:
    operation: createFTDNatPolicy
    path_params:
      domainUUID: "{{ domain_result.0.uuid }}"
    data:
      type: FTDNatPolicy
      name: "TEST-HA-NAT"

I get the following error message:

Get List of Objects Response from the server contains more objects than requested. There are 25 item(s) in the response while 10 was(ere) requested

Looking at the following code it seems like the DEFAULT_PAGE_SIZE is used to first fetch items to ensure idempotency:

https://github.com/CiscoDevNet/FMCAnsible/blob/9645714dea27dbb73c2decadc822a1dc4c0e06ad/plugins/module_utils/configuration.py#L686-L734

The problem is that it seems that the only way to override the DEFAULT_PAGE_SIZE it to set the limit in the query_params, but this is not allowed in a POST operation:

- name: Create NAT policy
  cisco.fmcansible.fmc_configuration:
    operation: createFTDNatPolicy
    path_params:
      domainUUID: "{{ domain_result.0.uuid }}"
   query_params:
      limit: 1000
    data:
      type: FTDNatPolicy
      name: "TEST-HA-NAT"

Results in:

Server returned an error trying to execute createFTDNatPolicy operation. Status code: 400. Server response: Invalid query parameter for the POST operation.

So, adding the limit fixes the first problem but causes another.

We need some way to override the DEFAULT_PAGE_SIZE without breaking the request.