ansible-collections / community.network

Ansible Community Network Collection
http://galaxy.ansible.com/community/network
Other
125 stars 90 forks source link

Netscaler_nitro_request should do url-/percent-encoding in the code instead of expecting already-encoded params #53

Open JonasVerhofste opened 4 years ago

JonasVerhofste commented 4 years ago
SUMMARY

As discussed in #52 , the module currently expects parameters to be url-/percent-encoded in the play (either hardcoded or through jinja-templating), whilst it would make more sense to do this in the module itself (making them easier to read and write).

ISSUE TYPE
COMPONENT NAME

netscaler_nitro_request

ADDITIONAL INFORMATION

Because of the weirdness that is the netscaler API, some parameters need to be url-encoded, whilst others don't. Currently, this is left up to the user: the code only builds the correct query, but doesn't do any parsing of the parameter-strings themselves. This makes for pretty confusing plays, where you have parameters that need {{ myvar | urlencode | replace('/', '%2F') }} and others don't.

It would make more sense to decide and do this in the code, making writing tasks a lot easier (as you don't need to go verify if this particular param needs encoding or not).

However, since changing this would be a backwards incompatible change, we'll have to feature flag this option, as kindly and correctly suggested by @felixfontein.

Example of how current tasks look:

- name: Do some filter
  netscaler_nitro_request:
    nsip: mynetscaler.mydomain.mytld
    nitro_user: myuser
    nitro_pass: mypass
    nitro_protocol: https
    operation: get_filtered
    resource: sslcertkey
    filter:
      certificatetype: "{{ '/ROOT_CERT|INTM_CERT/' | urlencode | replace('/', '%2F') }}"
      subject: "{{ '/COMODO/' | replace('/', '%2F') }}"

Example of how this would look with the feature flag:

- name: Do some filter
  netscaler_nitro_request:
    nsip: mynetscaler.mydomain.mytld
    nitro_user: myuser
    nitro_pass: mypass
    nitro_protocol: https
    operation: get_filtered
    resource: sslcertkey
    percent-encode: yes
    filter:
      certificatetype: /ROOT_CERT|INTM_CERT/
      subject: /COMODO/
ansibullbot commented 4 years ago

Files identified in the description:

If these files are inaccurate, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 4 years ago

cc @chiradeep @giorgos-nikolopoulos click here for bot help

ansibullbot commented 4 years ago

@JonasVerhofste, just so you are aware we have a dedicated Working Group for network. You can find other people interested in this in #ansible-network on Freenode IRC For more information about communities, meetings and agendas see https://github.com/ansible/community

click here for bot help