Skip to content

Commit

Permalink
Merge pull request #359 from netscaler/issue-352-lbvserver_servicegro…
Browse files Browse the repository at this point in the history
…up_binding

issue 352 lbvserver servicegroup binding
  • Loading branch information
sumanth-lingappa authored Feb 5, 2024
2 parents 10ccf32 + 05ca086 commit 4f4c662
Show file tree
Hide file tree
Showing 7 changed files with 227 additions and 9 deletions.
29 changes: 20 additions & 9 deletions plugins/module_utils/module_executor.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,16 +409,27 @@ def create_or_update(self):
)
else:
self.module_result["changed"] = True
log(
"INFO: Resource %s:%s exists. Will be UPDATED."
% (
self.resource_name,
self.resource_id,
if self.resource_name.endswith("_binding"):
# Generally bindings are not updated. They are removed and added again.
log(
"INFO: Resource %s:%s exists and is different. Will be REMOVED and ADDED."
% (self.resource_name, self.resource_id)
)
self.delete()
ok, err = create_resource(
self.client, self.resource_name, self.resource_module_params
)
else:
log(
"INFO: Resource %s:%s exists. Will be UPDATED."
% (
self.resource_name,
self.resource_id,
)
)
ok, err = update_resource(
self.client, self.resource_name, self.resource_module_params
)
)
ok, err = update_resource(
self.client, self.resource_name, self.resource_module_params
)
if not ok:
self.return_failure(err)

Expand Down
16 changes: 16 additions & 0 deletions plugins/modules/lbvserver_servicegroup_binding.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,22 @@
"""

EXAMPLES = r"""
- name: Create a lb
delegate_to: localhost
netscaler.adc.lbvserver:
name: test_lb
servicetype: SSL
- name: Create a servicegroup
delegate_to: localhost
netscaler.adc.servicegroup:
servicegroupname: test_sg
servicetype: SSL
- name: Create a servicegroup
delegate_to: localhost
netscaler.adc.lbvserver_servicegroup_binding:
weight: 1
name: test_lb
servicename: test_sg
"""

RETURN = r"""
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
gather_facts/no
netscaler/cpx/
netscaler/vpx/
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
---
- name: Include prerequisite tasks
ansible.builtin.include_tasks: setup.yaml
- name: LBVSERVER_SERVICEGROUP_BINDING | ADD | --check
delegate_to: localhost
register: result
check_mode: true
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | ADD | --check
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBVSERVER_SERVICEGROUP_BINDING | ADD
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | ADD
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBVSERVER_SERVICEGROUP_BINDING | ADD | idempotent
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | ADD | idempotent
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBVSERVER_SERVICEGROUP_BINDING | DELETE | --check
delegate_to: localhost
register: result
check_mode: true
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | DELETE | --check
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBVSERVER_SERVICEGROUP_BINDING | DELETE
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | DELETE
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==true"
- name: LBVSERVER_SERVICEGROUP_BINDING | DELETE | idempotent
delegate_to: localhost
register: result
check_mode: false
tags: test
netscaler.adc.lbvserver_servicegroup_binding:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
weight: 1
name: "{{ lb_name }}"
servicename: "{{ servicegroup_name }}"
- name: Assert | LBVSERVER_SERVICEGROUP_BINDING | DELETE | idempotent
tags: test
ansible.builtin.assert:
that:
- "result.failed==false"
- "result.changed==false"
- name: Include prerequisite tasks
ansible.builtin.include_tasks: teardown.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Create a lb
delegate_to: localhost
netscaler.adc.lbvserver:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
name: "{{ lb_name }}"
servicetype: SSL
- name: Create a servicegroup
delegate_to: localhost
netscaler.adc.servicegroup:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: present
servicegroupname: "{{ servicegroup_name }}"
servicetype: SSL
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
- name: Create a servicegroup
delegate_to: localhost
netscaler.adc.servicegroup:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
servicegroupname: "{{ servicegroup_name }}"
servicetype: SSL
- name: Create a lb
delegate_to: localhost
netscaler.adc.lbvserver:
nsip: "{{ nsip }}"
nitro_user: "{{ nitro_user }}"
nitro_pass: "{{ nitro_pass }}"
nitro_protocol: "{{ nitro_protocol }}"
validate_certs: "{{ validate_certs }}"
save_config: "{{ save_config }}"
state: absent
name: "{{ lb_name }}"
servicetype: SSL
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
lb_name: test_lb
servicegroup_name: test_sg

0 comments on commit 4f4c662

Please sign in to comment.