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
112 stars 57 forks source link

[Bug]: `lbvserver_rewritepolicy_binding` not detecting existing resources / always report changes #446

Open Callisto88 opened 3 months ago

Callisto88 commented 3 months ago

Summary

> show ns version
        NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)

pip freeze output

ansible==9.6.0
ansible-compat==24.6.0
ansible-core==2.16.7
ansible-lint==24.5.0
attrs==23.2.0
black==24.4.2
bracex==2.4
certifi==2024.2.2
cffi==1.16.0
charset-normalizer==3.3.2
click==8.1.7
cryptography==42.0.7
distro==1.9.0
dnspython==2.6.1
enrich==1.2.7
filelock==3.14.0
git-filter-repo==2.38.0
idna==3.7
importlib_metadata==7.1.0
Jinja2==3.1.4
jsonschema==4.22.0
jsonschema-specifications==2023.12.1
lxml==4.6.3
markdown-it-py==3.0.0
MarkupSafe==2.1.5
mdurl==0.1.2
mypy-extensions==1.0.0
packaging==24.0
passlib==1.7.4
pathspec==0.12.1
platformdirs==4.2.2
pyasn1==0.6.0
pyasn1_modules==0.4.0
pycparser==2.22
Pygments==2.18.0
pyspnego==0.10.2
python-ldap==3.4.0
pyvmomi==8.0.2.0.1
pywinrm==0.4.1
PyYAML==6.0.1
referencing==0.35.1
requests==2.32.3
requests-credssp==2.0.0
requests-ntlm==1.2.0
resolvelib==1.0.1
rich==13.7.1
rpds-py==0.18.1
ruamel.yaml==0.18.6
ruamel.yaml.clib==0.2.8
selinux==0.2.1
six==1.16.0
subprocess-tee==0.4.1
tenacity==8.3.0
tomli==2.0.1
typing_extensions==4.12.0
urllib3==2.2.1
wcmatch==8.5.2
xmltodict==0.13.0
yamllint==1.35.1
zipp==3.19.0

Issue Type

Bug Report

Component Name

lbvserver_rewritepolicy_binding

Python Version

$ python --version
Python 3.10.12

Ansible Version

$ ansible --version
ansible [core 2.16.7]
  config file = /home/user/git/company/infra/customers/test/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/git/company/infra/customers/test/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/git/company/infra/customers/test/venv/bin/ansible
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] ( /home/user/git/company/infra/customers/test/venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True

Ansible Configuration

$ ansible-config dump --only-changed

CONFIG_FILE() = /home/user/git/company/infra/customers/test/ansible.cfg
DEFAULT_ROLES_PATH(/home/user/git/company/infra/customers/test/ansible.cfg) = ['/home/user/git/company/infra/customers/test/"roles', '/home/user/git/company/infra/customers/test/roles', '/usr/share/ansible>
PAGER(env: PAGER) = less

netscaler.adc Collection Version

$ ansible-galaxy collection list netscaler.adc

# /home/cydb/.ansible/collections/ansible_collections
Collection    Version
------------- -------
netscaler.adc 2.6.1

Target NetScaler Version

> show ns version

Equivalent NetScaler CLI Command

bind lb vserver LBVS_Keycloak -policyName RP_Insert_X_Forwarded_Proto -priority 100 -gotoPriorityExpression NEXT -type REQUEST

Steps to Reproduce

{16:43}~/git/company/infra/customers/test:contrib/netscaler ✗ ➭ ansible-playbook -i inventory/hosts.yml -D playbooks/netscaler.yml --vault-password-file .vault-password --start-at-task="Bind rewrite policies and LBVS" -vvv

ansible-playbook [core 2.16.7]
  config file = /home/user/git/company/infra/customers/test/ansible.cfg
  configured module search path = ['/home/user/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/user/git/company/infra/customers/test/venv/lib/python3.10/site-packages/ansible
  ansible collection location = /home/user/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/user/git/company/infra/customers/test/venv/bin/ansible-playbook
  python version = 3.10.12 (main, Nov 20 2023, 15:14:05) [GCC 11.4.0] (/home/user/git/company/infra/customers/test/venv/bin/python3)
  jinja version = 3.1.4
  libyaml = True
Using /home/user/git/company/infra/customers/test/ansible.cfg as config file
host_list declined parsing /home/user/git/company/infra/customers/test/inventory/hosts-kc-prd.yml as it did not pass its verify_file() method
script declined parsing /home/user/git/company/infra/customers/test/inventory/hosts-kc-prd.yml as it did not pass its verify_file() method
Parsed /home/user/git/company/infra/customers/test/inventory/hosts-kc-prd.yml inventory source with yaml plugin
Skipping callback 'default', as we already have a stdout callback.
Skipping callback 'minimal', as we already have a stdout callback.
Skipping callback 'oneline', as we already have a stdout callback.

PLAYBOOK: netscaler.yml ********************************************************************************************************************************************************************
1 plays in playbooks/netscaler.yml

PLAY [NetScaler] ***************************************************************************************************************************************************************************

TASK [Bind rewrite policies and LBVS] ******************************************************************************************************************************************************
task path: /home/user/git/company/infra/customers/test/playbooks/netscaler.yml:494
<NSIP> ESTABLISH LOCAL CONNECTION FOR USER: test
<NSIP> EXEC /bin/sh -c 'echo ~test && sleep 0'
<NSIP> EXEC /bin/sh -c '( umask 77 && mkdir -p "` echo /home/user/.ansible/tmp `"&& mkdir "` echo /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893 `" && echo ansible-tmp-1719326890.8583844-1537215-210629528290893="` echo /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893 `" ) && sleep 0'
<HOSTNAME> Attempting python interpreter discovery
<NSIP> EXEC /bin/sh -c 'echo PLATFORM; uname; echo FOUND; command -v '"'"'python3.12'"'"'; command -v '"'"'python3.11'"'"'; command -v '"'"'python3.10'"'"'; command -v '"'"'python3.9'"'"'; command -v '"'"'python3.8'"'"'; command -v '"'"'python3.7'"'"'; command -v '"'"'python3.6'"'"'; command -v '"'"'/usr/bin/python3'"'"'; command -v '"'"'/usr/libexec/platform-python'"'"'; command -v '"'"'python2.7'"'"'; command -v '"'"'/usr/bin/python'"'"'; command -v '"'"'python'"'"'; echo ENDFOUND && sleep 0'
<NSIP> EXEC /bin/sh -c '/home/user/git/company/infra/customers/test/venv/bin/python3.10 && sleep 0'
Using module file /home/user/.ansible/collections/ansible_collections/netscaler/adc/plugins/modules/lbvserver_rewritepolicy_binding.py
<NSIP> PUT /home/user/.ansible/tmp/ansible-local-15371558v8cicyp/tmpfpovnlkh TO /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893/AnsiballZ_lbvserver_rewritepolicy_binding.py
<NSIP> EXEC /bin/sh -c 'chmod u+x /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893/ /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893/AnsiballZ_lbvserver_rewritepolicy_binding.py && sleep 0'
<NSIP> EXEC /bin/sh -c '/usr/bin/python3 /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893/AnsiballZ_lbvserver_rewritepolicy_binding.py && sleep 0'
<NSIP> EXEC /bin/sh -c 'rm -f -r /home/user/.ansible/tmp/ansible-tmp-1719326890.8583844-1537215-210629528290893/ > /dev/null 2>&1 && sleep 0'
--- before
+++ after
@@ -1 +1,7 @@
-{}
+{
+    "bindpoint": "REQUEST",
+    "gotopriorityexpression": "NEXT",
+    "name": "LBVS_Keycloak",
+    "policyname": "RP_Insert_X_Forwarded_Proto",
+    "priority": 100.0
+}

changed: [HOSTNAME] => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/bin/python3"
    },
    "changed": true,
    "diff": {
        "after": {
            "bindpoint": "REQUEST",
            "gotopriorityexpression": "NEXT",
            "name": "LBVS_Keycloak",
            "policyname": "RP_Insert_X_Forwarded_Proto",
            "priority": 100.0
        },
        "before": {}
    },
    "invocation": {
        "module_args": {
            "api_path": "nitro/v1/config",
            "bindpoint": "REQUEST",
            "gotopriorityexpression": "NEXT",
            "invoke": null,
            "labelname": null,
            "labeltype": null,
            "managed_netscaler_instance_id": null,
            "managed_netscaler_instance_ip": null,
            "managed_netscaler_instance_name": null,
            "managed_netscaler_instance_password": null,
            "managed_netscaler_instance_username": null,
            "name": "LBVS_Keycloak",
            "netscaler_console_as_proxy_server": false,
            "nitro_auth_token": null,
            "nitro_pass": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "nitro_protocol": "https",
            "nitro_user": "VALUE_SPECIFIED_IN_NO_LOG_PARAMETER",
            "nsip": "NSIP",
            "order": null,
            "policyname": "RP_Insert_X_Forwarded_Proto",
            "priority": 100.0,
            "save_config": false,
            "state": "present",
            "validate_certs": false
        }
    },
    "loglines": [
        "DEBUG: Initializing ModuleExecutor for resource lbvserver_rewritepolicy_binding",
        "TRACE: ENTRY: common.get_valid_desired_states() called with ('lbvserver_rewritepolicy_binding',), {}",
        "TRACE: EXIT: common.get_valid_desired_states() returned {'absent', 'present'}",
        "TRACE: ENTRY: common.get_netscaler_version() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>,), {}",
        "TRACE: ENTRY: common.get_resource() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'nsversion'), {}",
        "WARNING: Resource name nsversion not found in NITRO_RESOURCE_MAP to get get_arg_keys",
        "TRACE: ENTRY: client.get() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>,), {'resource': 'nsversion', 'id': None, 'args': {}}",
        "TRACE: ENTRY: client.url_builder() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'nsversion'), {'id': None, 'args': {}, 'attrs': None, 'filter': None}",
        "TRACE: EXIT: client.url_builder() returned https://NSIP/nitro/v1/config/nsversion",
        "TRACE: ENTRY: client.send() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'GET', 'https://NSIP/nitro/v1/config/nsversion'), {}",
        "DEBUG: self={'_module': <ansible.module_utils.basic.AnsibleModule object at 0x7fa2fe8d87c0>, 'check_mode': False, 'api_path': 'nitro/v1/config', 'resource_name': 'lbvserver_rewritepolicy_binding', '_headers': {'Content-Type': 'application/json', 'User-Agent': 'ansible-ctxadc', 'X-NITRO-USER': '********', 'X-NITRO-PASS': '********'}}",
        "DEBUG: fetch_url()-resonse-info= GET: {'url': 'https://NSIP/nitro/v1/config/nsversion', 'status': 200, 'date': 'Tue, 25 Jun 2024 14:48:13 GMT', 'server': 'Apache', 'x-frame-options': 'SAMEORIGIN', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'pragma': 'no-cache', 'vary': 'Accept-Encoding', 'feature-policy': \"camera 'none'; microphone 'none'; geolocation 'none'\", 'referrer-policy': 'no-referrer', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-length': '201', 'content-type': 'application/json; charset=utf-8', 'connection': 'close', 'cookies_string': '', 'cookies': {}, 'msg': 'OK (201 bytes)'}",
        "TRACE: EXIT: client.send() returned (200, {'errorcode': 0, 'message': 'Done', 'severity': 'NONE', 'nsversion': {'installedversion': False, 'version': 'NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)', 'mode': '1'}})",
        "TRACE: EXIT: client.get() returned (200, {'errorcode': 0, 'message': 'Done', 'severity': 'NONE', 'nsversion': {'installedversion': False, 'version': 'NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)', 'mode': '1'}})",
        "TRACE: ENTRY: common.fix_nitro_anomolies() called with ('nsversion', {}, [{'installedversion': False, 'version': 'NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)', 'mode': '1'}]), {}",
        "TRACE: EXIT: common.fix_nitro_anomolies() returned [{'installedversion': False, 'version': 'NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)', 'mode': '1'}]",
        "TRACE: EXIT: common.get_resource() returned (True, [{'installedversion': False, 'version': 'NetScaler NS14.1: Build 21.57.nc, Date: Apr 18 2024, 16:06:59   (64-bit)', 'mode': '1'}])",
        "TRACE: EXIT: common.get_netscaler_version() returned (14.1, 21.57)",
        "INFO: NetScaler version: 14.1-21.57",
        "DEBUG: All params (including non module-specific params) are: {'nsip': 'NSIP', 'nitro_user': '********', 'nitro_pass': '********', 'nitro_protocol': 'https', 'validate_certs': False, 'save_config': False, 'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0, 'api_path': 'nitro/v1/config', 'netscaler_console_as_proxy_server': False, 'state': 'present', 'nitro_auth_token': None, 'managed_netscaler_instance_name': None, 'managed_netscaler_instance_ip': None, 'managed_netscaler_instance_id': None, 'managed_netscaler_instance_username': None, 'managed_netscaler_instance_password': None, 'invoke': None, 'labelname': None, 'labeltype': None, 'order': None}",
        "TRACE: ENTRY: module_executor._filter_resource_module_params() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {}",
        "DEBUG: self.module.params: {'nsip': 'NSIP', 'nitro_user': '********', 'nitro_pass': '********', 'nitro_protocol': 'https', 'validate_certs': False, 'save_config': False, 'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0, 'api_path': 'nitro/v1/config', 'netscaler_console_as_proxy_server': False, 'state': 'present', 'nitro_auth_token': None, 'managed_netscaler_instance_name': None, 'managed_netscaler_instance_ip': None, 'managed_netscaler_instance_id': None, 'managed_netscaler_instance_username': None, 'managed_netscaler_instance_password': None, 'invoke': None, 'labelname': None, 'labeltype': None, 'order': None}",
        "DEBUG: Desired `lbvserver_rewritepolicy_binding` module specific params are: {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}",
        "TRACE: EXIT: module_executor._filter_resource_module_params() returned None",
        "TRACE: ENTRY: module_executor.get_existing_resource() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {}",
        "TRACE: ENTRY: common.get_resource() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>,), {'resource_name': 'lbvserver_rewritepolicy_binding', 'resource_id': 'LBVS_Keycloak', 'resource_module_params': {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}}",
        "TRACE: ENTRY: client.get() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>,), {'resource': 'lbvserver_rewritepolicy_binding', 'id': 'LBVS_Keycloak', 'filter': {'bindpoint': 'REQUEST', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}}",
        "TRACE: ENTRY: client.url_builder() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'lbvserver_rewritepolicy_binding'), {'id': 'LBVS_Keycloak', 'args': None, 'attrs': None, 'filter': {'bindpoint': 'REQUEST', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}}",
        "TRACE: EXIT: client.url_builder() returned https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding/LBVS_Keycloak?filter=bindpoint:REQUEST,policyname:RP_Insert_X_Forwarded_Proto,priority:100.0",
        "TRACE: ENTRY: client.send() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'GET', 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding/LBVS_Keycloak?filter=bindpoint:REQUEST,policyname:RP_Insert_X_Forwarded_Proto,priority:100.0'), {}",
        "DEBUG: self={'_module': <ansible.module_utils.basic.AnsibleModule object at 0x7fa2fe8d87c0>, 'check_mode': False, 'api_path': 'nitro/v1/config', 'resource_name': 'lbvserver_rewritepolicy_binding', '_headers': {'Content-Type': 'application/json', 'User-Agent': 'ansible-ctxadc', 'X-NITRO-USER': '********', 'X-NITRO-PASS': '********'}}",
        "DEBUG: fetch_url()-resonse-info= GET: {'url': 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding/LBVS_Keycloak?filter=bindpoint:REQUEST,policyname:RP_Insert_X_Forwarded_Proto,priority:100.0', 'status': 200, 'date': 'Tue, 25 Jun 2024 14:48:13 GMT', 'server': 'Apache', 'x-frame-options': 'SAMEORIGIN', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'pragma': 'no-cache', 'vary': 'Accept-Encoding', 'feature-policy': \"camera 'none'; microphone 'none'; geolocation 'none'\", 'referrer-policy': 'no-referrer', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-length': '57', 'content-type': 'application/json; charset=utf-8', 'connection': 'close', 'cookies_string': '', 'cookies': {}, 'msg': 'OK (57 bytes)'}",
        "TRACE: EXIT: client.send() returned (200, {'errorcode': 0, 'message': 'Done', 'severity': 'NONE'})",
        "TRACE: EXIT: client.get() returned (200, {'errorcode': 0, 'message': 'Done', 'severity': 'NONE'})",
        "TRACE: EXIT: common.get_resource() returned (False, [])",
        "TRACE: EXIT: module_executor.get_existing_resource() returned {}",
        "TRACE: ENTRY: module_executor.main() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {}",
        "TRACE: ENTRY: module_executor.create_or_update() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {}",
        "TRACE: ENTRY: module_executor.update_diff_list() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {'existing': {}, 'desired': {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}}",
        "TRACE: EXIT: module_executor.update_diff_list() returned None",
        "INFO: Resource lbvserver_rewritepolicy_binding:LBVS_Keycloak does not exist. Will be CREATED.",
        "TRACE: ENTRY: common.create_resource() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'lbvserver_rewritepolicy_binding', {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}), {}",
        "TRACE: ENTRY: common._check_create_resource_params() called with ('lbvserver_rewritepolicy_binding', {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}), {}",
        "TRACE: EXIT: common._check_create_resource_params() returned (True, None, {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0})",
        "TRACE: ENTRY: client.post() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>,), {'post_data': {'lbvserver_rewritepolicy_binding': {'bindpoint': 'REQUEST', 'gotopriorityexpression': 'NEXT', 'name': 'LBVS_Keycloak', 'policyname': 'RP_Insert_X_Forwarded_Proto', 'priority': 100.0}}, 'resource': 'lbvserver_rewritepolicy_binding', 'action': None}",
        "TRACE: ENTRY: client.url_builder() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'lbvserver_rewritepolicy_binding'), {'action': None}",
        "TRACE: EXIT: client.url_builder() returned https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding",
        "TRACE: ENTRY: client.send() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'POST', 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding', '{\"lbvserver_rewritepolicy_binding\": {\"bindpoint\": \"REQUEST\", \"gotopriorityexpression\": \"NEXT\", \"name\": \"LBVS_Keycloak\", \"policyname\": \"RP_Insert_X_Forwarded_Proto\", \"priority\": 100.0}}'), {}",
        "DEBUG: self={'_module': <ansible.module_utils.basic.AnsibleModule object at 0x7fa2fe8d87c0>, 'check_mode': False, 'api_path': 'nitro/v1/config', 'resource_name': 'lbvserver_rewritepolicy_binding', '_headers': {'Content-Type': 'application/json', 'User-Agent': 'ansible-ctxadc', 'X-NITRO-USER': '********', 'X-NITRO-PASS': '********'}}",
        "DEBUG: fetch_url()-resonse-info= POST: {'url': 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding', 'status': 201, 'date': 'Tue, 25 Jun 2024 14:48:13 GMT', 'server': 'Apache', 'x-frame-options': 'SAMEORIGIN', 'expires': 'Thu, 19 Nov 1981 08:52:00 GMT', 'cache-control': 'no-store, no-cache, must-revalidate, post-check=0, pre-check=0', 'pragma': 'no-cache', 'feature-policy': \"camera 'none'; microphone 'none'; geolocation 'none'\", 'referrer-policy': 'no-referrer', 'x-xss-protection': '1; mode=block', 'x-content-type-options': 'nosniff', 'content-length': '0', 'content-type': 'text/html; charset=UTF-8', 'connection': 'close', 'cookies_string': '', 'cookies': {}, 'msg': 'OK (0 bytes)'}",
        "TRACE: EXIT: client.send() returned (201, {})",
        "TRACE: EXIT: client.post() returned (201, {})",
        "TRACE: ENTRY: common.return_response() called with (), {'status_code': 201, 'response_body': {}, 'operation': 'create_resource', 'resource_name': 'lbvserver_rewritepolicy_binding'}",
        "DEBUG: create_resource lbvserver_rewritepolicy_binding SUCCESS",
        "TRACE: EXIT: common.return_response() returned (True, {})",
        "TRACE: EXIT: common.create_resource() returned (True, {})",
        "TRACE: EXIT: module_executor.create_or_update() returned None",
        "TRACE: ENTRY: module_executor.return_success() called with (<ansible_collections.netscaler.adc.plugins.module_utils.module_executor.ModuleExecutor object at 0x7fa2fe8d9900>,), {}"
    ]
}

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

Re-run the playbook, get the exact same result

Expected Results

Expect the Ansible run to detect the existing binding

Actual Results

The run report changes everytime. Even though the instructions is present in the Netscaler

Additional Notes

No response

Callisto88 commented 3 months ago

I think i have spotted the problem while troubleshooting netscaler.adc.csvserver_cspolicy_binding module

The request sent to the Netscaler API is as follow :

"TRACE: ENTRY: client.send() called with (<ansible_collections.netscaler.adc.plugins.module_utils.client.NitroAPIClient object at 0x7fa2fe8d9a20>, 'GET', 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding/LBVS_Keycloak?filter=bindpoint:REQUEST,policyname:RP_Insert_X_Forwarded_Proto,priority:100.0'), {}",

In the filter arguments the priority is specified as a floating number ( 100.0 ) BUT in the Netscaler it wants a positiv integer

> bind cs vserver CSVS_OnCall_Web -policyName CSP_OnCall_Web_RealTimeAPI -priority 110.0
                                                                                   ^^^^^
ERROR: Invalid value [unsigned integer, 110.0]

Replaying the same request with priority as an integer and tadaa it works

'GET', 'https://NSIP/nitro/v1/config/lbvserver_rewritepolicy_binding/LBVS_Keycloak?filter=bindpoint:REQUEST,policyname:RP_Insert_X_Forwarded_Proto,priority:100'), {}

So i guess it's the same problem since it also use priority parameter. I don't know about the others modules but could be affected as well.

I found this part of the code that might be responsible for this but quite unsure how to fix it. I would be grateful if anyone more Python skilled could do PR to address this.

https://github.com/netscaler/ansible-collection-netscaleradc/blob/56f27127c18e514bb308acfa0b49ba67b3c81d58/plugins/module_utils/module_executor.py#L205

Callisto88 commented 3 months ago

Meanwhile, a quick & dirty fix

( this is the change for csvserver_cspolicy_binding but most probably applicable to other *_binding module

In plugins/module_utils/nitro_resource_map.py

@@ -24441,7 +24441,7 @@
             },
             "name": {"no_log": False, "type": "str"},
             "policyname": {"no_log": False, "type": "str"},
-            "priority": {"no_log": False, "type": "float"},
+            "priority": {"no_log": False, "type": "int"},
             "targetlbvserver": {"no_log": False, "type": "str"},
         },
         "singleton": False,