Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug]: The modules that contains memebers binding can not identify the changing correctly #457

Open
petetong1989 opened this issue Sep 18, 2024 · 0 comments
Labels

Comments

@petetong1989
Copy link

petetong1989 commented Sep 18, 2024

Summary

The netscaler ansible module that has the member binding field, has an issue that can not correctly identify the binding change. e.g. the VLAN module contains the field called vlan_interface_binding. Every time I pass over the binding config change to this module, the module will fail to determine the change for me, instead, it will consider re-applying the config from top to bottom in case I just want to add on a particular binding config and remain the others.
I found it is not just the VLAN module that has such a problem.

Pasted the code snippet below, the desired_binding_members shouldn't be passed over entirely to self.add_binding method. and this is a public method used by all the Netscaler modules which contains the binding members feature.

This collected code snippet is from ModuleExecutor.sync_single_binding

        if binding_mode == "desired":
            # In `desired` mode, we will check if the existing bindings are identical to the desired
            # bindings, if not, we will delete the existing bindings and add the desired bindings.
            # If they are identical, we will do nothing. If there are no existing bindings,
            # we will add the desired bindings. If there are no desired bindings,
            # we will delete the existing bindings. If there are no existing and desired bindings,
            # we will do nothing.

            log(
                "INFO: to_be_deleted_bindprimary_keys bindings: %s"
                % to_be_deleted_bindprimary_keys
            )
            log(
                "INFO: to_be_added_bindprimary_keys bindings: %s"
                % to_be_added_bindprimary_keys
            )
            log(
                "INFO: to_be_updated_bindprimary_keys bindings: %s"
                % to_be_updated_bindprimary_keys
            )

            if to_be_added_bindprimary_keys:
                self.add_bindings(
                    binding_name=binding_name,
                    desired_bindings=desired_binding_members,
                )

Issue Type

Bug Report

Component Name

The module contains binding_members feature.

Python Version

Python 3.10.14

Ansible Version

ansible [core 2.14.15]
  config file = /Users/pzhang/vscode/Project/network_ansible/ansible.cfg
  configured module search path = ['/Users/pzhang/vscode/Project/network_ansible/library/custom_modules/plugins/modules', '/Users/pzhang/vscode/Project/network_ansible/site-packages/citrix_sdx_ansible/modules']
  ansible python module location = /Users/pzhang/miniconda3/envs/network_ansible/lib/python3.10/site-packages/ansible
  ansible collection location = /Users/pzhang/vscode/Project/network_ansible/site-packages
  executable location = /Users/pzhang/miniconda3/envs/network_ansible/bin/ansible
  python version = 3.10.14 (main, Mar 21 2024, 11:24:58) [Clang 14.0.6 ] (/Users/pzhang/miniconda3/envs/network_ansible/bin/python)
  jinja version = 3.0.0
  libyaml = True

Ansible Configuration

$ ansible-config dump --only-changed

netscaler.adc Collection Version

# /Users/pzhang/miniconda3/envs/network_ansible/lib/python3.10/site-packages/ansible_collections
Collection    Version
------------- -------
netscaler.adc 2.6.1  

# /Users/pzhang/vscode/Project/network_ansible/site-packages/ansible_collections
Collection    Version
------------- -------
netscaler.adc 2.6.1  

Target NetScaler Version

NetScaler NS13.1: Build 52.19.nc, Date: Feb 29 2024, 09:44:08   (64-bit)

Equivalent NetScaler CLI Command

Steps to Reproduce

Sample playbook

- name: "Set VLANs(routed_snips)"
  delegate_to: localhost
   netscaler.adc.vlan:
     nsip: "{{  nsip }}"
     state: "{{ item.state | default('present') }}"
     validate_certs: false
     nitro_user: "{{ ansible_user }}"
     nitro_pass: "{{ ansible_ssh_pass }}"
     id: "{{ id }}"
     aliasname: "{{ aliasname }}"
     vlan_nsip_binding:
       binding_members: "{{ snip_bindings }}"

Sample variables

vlan: 999
aliasname: test_vlan

snip_bindings:
  - id: 999
    ipaddress: 192.168.1.1
    netmask: 255.255.255.0
    ownergroup: ng1
    ... <binding more than one ipaddress, let say just try with binding one more snip>

The play result will show you that it changes all the binding states including 192.168.1.1 if we assume this binding config is already exists before you add other binding configs.

Expected Results

The module is capable of accurately reflecting and displaying any updates or modifications to the binding configuration settings within the system.

Actual Results

Additional Notes

Please be aware, this phenomenon doesn't just exist in Netscaler VLAN module, it also exists in others.

@sumanth-lingappa sumanth-lingappa linked a pull request Sep 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant