New module: manage Citrix Netscaler service configuration (network/netscaler/netscaler_service) (#25129)

* netscaler_service initial implementation

* Changes as requested by reviewers

* Skip some tests if under python2.6 and importing requests library

* Change option "operation" to "state"

* Remove print statements from netscaler module utils

* Catch all exceptions during login

* Fix fail message

* Add common option save_config
This commit is contained in:
George Nikolopoulos 2017-06-08 17:33:32 +03:00 committed by Chris Alfonso
commit a00089c341
24 changed files with 2328 additions and 0 deletions

View file

@ -0,0 +1,11 @@
- hosts: netscaler
gather_facts: no
connection: local
vars:
limit_to: "*"
debug: false
roles:
- { role: netscaler_service, when: "limit_to in ['*', 'netscaler_service']" }

View file

@ -0,0 +1,6 @@
---
testcase: "*"
test_cases: []
nitro_user: nsroot
nitro_pass: nsroot

View file

@ -0,0 +1,5 @@
[netscaler]
172.18.0.2 nsip=172.18.0.2 nitro_user=nsroot nitro_pass=nsroot

View file

@ -0,0 +1,2 @@
---
- { include: nitro.yaml, tags: ['nitro'] }

View file

@ -0,0 +1,14 @@
- name: collect all nitro test cases
find:
paths: "{{ role_path }}/tests/nitro"
patterns: "{{ testcase }}.yaml"
register: test_cases
- name: set test_items
set_fact: test_items="{{ test_cases.files | map(attribute='path') | list }}"
- name: run test case
include: "{{ test_case_to_run }}"
with_items: "{{ test_items }}"
loop_control:
loop_var: test_case_to_run

View file

@ -0,0 +1,57 @@
---
- include: "{{ role_path }}/tests/nitro/adns_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/setup.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/setup.yaml"
vars:
check_mode: no
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/remove.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/adns_service/remove.yaml"
vars:
check_mode: no
- assert:
that: not result|changed

View file

@ -0,0 +1,14 @@
---
- name: Remove adns service
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: absent
name: service-adns

View file

@ -0,0 +1,17 @@
---
- name: Setup adns service
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: present
name: service-adns
ipaddress: 192.168.1.3
port: 80
servicetype: ADNS

View file

@ -0,0 +1,85 @@
---
- include: "{{ role_path }}/tests/nitro/http_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/setup.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/http_service/setup.yaml"
vars:
check_mode: no
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/http_service/update.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/update.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/update.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/http_service/update.yaml"
vars:
check_mode: no
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/http_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/remove.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/http_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/http_service/remove.yaml"
vars:
check_mode: no
- assert:
that: not result|changed

View file

@ -0,0 +1,16 @@
---
- name: Remove htttp service
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: absent
name: service-http
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"

View file

@ -0,0 +1,53 @@
---
- name: Setup http service
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: present
name: service-http
ip: 192.168.1.1
ipaddress: 192.168.1.1
port: 80
servicetype: HTTP
cachetype: TRANSPARENT
maxclient: 100
healthmonitor: no
maxreq: 200
cacheable: no
cip: ENABLED
cipheader: client-ip
usip: yes
useproxyport: yes
sc: off
sp: off
rtspsessionidremap: off
clttimeout: 100
svrtimeout: 100
customserverid: 476
cka: yes
tcpb: yes
cmp: no
maxbandwidth: 10000
accessdown: "NO"
monthreshold: 100
downstateflush: ENABLED
hashid: 10
comment: some comment
appflowlog: ENABLED
processlocal: ENABLED
graceful: no
monitor_bindings:
- monitorname: ping
weight: 50
- monitorname: http
weight: 50
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"

View file

@ -0,0 +1,51 @@
---
- name: Update http service
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: present
name: service-http
ip: 192.168.1.1
ipaddress: 192.168.1.1
port: 80
servicetype: HTTP
cachetype: TRANSPARENT
maxclient: 100
healthmonitor: no
maxreq: 200
cacheable: no
cip: ENABLED
cipheader: client-ip
usip: yes
useproxyport: yes
sc: off
sp: off
rtspsessionidremap: off
clttimeout: 100
svrtimeout: 100
customserverid: 476
cka: yes
tcpb: yes
cmp: no
maxbandwidth: 20000
accessdown: "NO"
monthreshold: 100
downstateflush: ENABLED
hashid: 10
comment: some comment
appflowlog: ENABLED
processlocal: ENABLED
netprofile: net-profile-1
monitor_bindings:
- monitorname: http
weight: 100
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"

View file

@ -0,0 +1,57 @@
---
- include: "{{ role_path }}/tests/nitro/ssl_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/setup.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/setup.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/setup.yaml"
vars:
check_mode: no
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/remove.yaml"
vars:
check_mode: no
- assert:
that: result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/remove.yaml"
vars:
check_mode: yes
- assert:
that: not result|changed
- include: "{{ role_path }}/tests/nitro/ssl_service/remove.yaml"
vars:
check_mode: no
- assert:
that: not result|changed

View file

@ -0,0 +1,14 @@
---
- name: Remove ssl service
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: absent
name: service-ssl

View file

@ -0,0 +1,18 @@
---
- name: Setup ssl service
delegate_to: localhost
register: result
check_mode: "{{ check_mode }}"
netscaler_service:
nitro_user: "{{nitro_user}}"
nitro_pass: "{{nitro_pass}}"
nsip: "{{nsip}}"
state: present
name: service-ssl
ipaddress: 192.168.1.2
port: 80
servicetype: SSL
cleartextport: 88