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

issue 352 lbvserver servicegroup binding #359

Merged
merged 3 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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