netscaler / ansible-collection-netscaleradc

Custom Ansible modules for NetScaler ADC and NetScaler ADM. Part of NetScaler Automation Toolkit | https://github.com/netscaler/automation-toolkit
https://netscaler.github.io/ansible-collection-netscaleradc/
MIT License
113 stars 57 forks source link

[FEATURE REQUEST] _info modules #296

Open fa-elepape opened 1 year ago

fa-elepape commented 1 year ago

Is your feature request related to a problem? Please describe. While the new collection lets Ansible manage pretty much all aspects of Netscaler, it's not currently possible to retrieve information from them.

In my current case, I'm attempting to renew certificates which are relatively close to expiry but retrieving that information is not readily available from _info modules (see vmware.vmware_rest for an example) which means I have to fall back to using the ansible.builtin.uri module to perform those requests.

I'm raising this feature request to make this more "Ansibly" but it's clearly not a blocker.

Describe the solution you'd like Add corresponding _info modules to the existing modules.

Describe alternatives you've considered Again, this is not (for me) a blocking issue since I can perform the requests manually for now, it's just more cumbersome.

sumanth-lingappa commented 11 months ago

@fa-elepape, thank you for the enhancement request. This is a very apt ask. We will definitely keep this in our planning.

Can you please share your workaround using ansible.builtin.uri which you mentioned?

fa-elepape commented 11 months ago

Sure! It's really just a dump of the /sslcertkey endpoint of the NITRO API which can then be manipulated using Ansible. It's quite close to what was documented in the citrix.adc branch.

ansible.builtin.uri:
  url: "{{ nitro_protocol }}://{{ nsip }}/nitro/v1/config/sslcertkey"
  method: GET
  status_code: 200
  return_content: yes
  headers:
    X-NITRO-USER: "{{ nitro_user }}"
    X-NITRO-PASS: "{{ nitro_pass }}"
  validate_certs: "{{ validate_certs }}"
vars:
  nitro_pass: "{{ netscaler_nitro_pass | default(lookup('ansible.builtin.env', 'NETSCALER_NITRO_PASS', default=omit)) }}"
  nitro_protocol: "{{ netscaler_nitro_protocol | default(lookup('ansible.builtin.env', 'NETSCALER_NITRO_PROTOCOL')) }}"
  nitro_user: "{{ netscaler_nitro_user | default(lookup('ansible.builtin.env', 'NETSCALER_NITRO_USER', default=omit)) }}"
  nsip: "{{ netscaler_nsip | default(lookup('ansible.builtin.env', 'NETSCALER_NSIP', default=omit)) }}"
  validate_certs: "{{ netscaler_validate_certs | default(lookup('ansible.builtin.env', 'NETSCALER_VALIDATE_CERTS', default=omit)) }}"
gusmb commented 4 months ago

This is close to #372. I think an Ansible lookup plugin could be a better fit for this. Lookup plugins to run any sort of query for data can be used within an Ansible task, but also directly with Jinja templates, and there might be situations where the query is built on runtime during a template rendering. Lookups are powerful and support Ansible loops as well.

Here an example of how a resource lookup query could be run https://github.com/netscaler/ansible-collection-netscaleradc/issues/372#issuecomment-1996907073