Skip to content

Commit

Permalink
Merge pull request #333 from netscaler/issue-324
Browse files Browse the repository at this point in the history
Issue: #324: for a NetScaler side bug, added a workaround in the coll…
  • Loading branch information
sumanth-lingappa authored Jan 5, 2024
2 parents 4f7e030 + 35f3c44 commit 3d5e046
Show file tree
Hide file tree
Showing 3 changed files with 156 additions and 0 deletions.
18 changes: 18 additions & 0 deletions plugins/module_utils/module_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,24 @@ def get_existing_resource(self):
self.return_failure(msg)

self.existing_resource = existing_resource[0] if existing_resource else {}
# FIXME: in lbmonitor, for `interval=60`, the `units3` will wrongly be set to `MIN` by the NetScaler.
# Hence, we will set it to `SEC` to make it idempotent
# Refer Issue: #324 (https://github.com/netscaler/ansible-collection-netscaleradc/issues/324)
if self.resource_name == "lbmonitor":
# default value for `units3` is `SEC`
if (
"units3" not in self.resource_module_params
or self.resource_module_params["units3"] == "SEC"
):
if (
"units3" in self.existing_resource
and self.existing_resource["units3"] == "MIN"
):
self.existing_resource["interval"] = (
int(self.existing_resource["interval"]) * 60
)
self.existing_resource["units3"] = "SEC"

return self.existing_resource

@trace
Expand Down
1 change: 1 addition & 0 deletions tests/integration/targets/lbmonitor/aliases
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
gather_facts/no
137 changes: 137 additions & 0 deletions tests/integration/targets/lbmonitor/tasks/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
---
- name: LBMONITOR | ADD | --check
delegate_to: localhost
register: result
check_mode: true
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | ADD | --check
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBMONITOR | ADD
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | ADD
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBMONITOR | ADD | idempotent
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | ADD | idempotent
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==false"
- name: LBMONITOR | DELETE | --check
delegate_to: localhost
register: result
check_mode: true
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | DELETE | --check
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBMONITOR | DELETE
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | DELETE
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBMONITOR | DELETE | idempotent
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbmonitor:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
monitorname: test-lb-monitor
interval: 60
type: HTTP
deviation: 0
- name: Assert | LBMONITOR | DELETE | idempotent
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==false"

0 comments on commit 3d5e046

Please sign in to comment.