I want to fetch the netscaler partition list and fetch the all the ssl certificate from all the partition in it to apply manipulation on fetched facts regarding sslcertificate and sslcertkey for renewal.
Also, i can not able to switch to the partition using both nspartition module and nitro api call too. and as per latest netscaler.adc collection we don’t have any fact module to gather facts regarding modules to fetch the facts.
i am runnig with following tools and version:
python version using 3.6.8
python3 version using 3.8.12
netscaler.adc: 2.6.1
netscaler box version : 14.1-25.56
ansible version: 2.13.13
- my code!
- name: Partition details and ssl certkey in the partition
hosts: localhost
connection: ansible.netcommon.network_cli
gather_facts: false
collections:
- netscaler.adc
vars:
netscaler: " enter ipaddress"
netscaler_pass: "enter password"
tasks:
- name: List the partition and details
block:
- name: Login to netscale adc
netscaler.adc.login:
nsip: "{{ netscaler }}"
username: "enter username"
password: "{{ netscaler_pass }}"
validate_certs: false
register: login_result
- name: Display the login result information to retrieve session id
ansible.builtin.debug:
var: login_result
- name: Get the netscaler partition list
netscaler.adc.nspartition:
nsip: "{{ netscaler }}"
nitro_auth_token: "{{ login_result.sessionid }}"
partitionname: default
state: switched
validate_certs: false
register: partition_list
- name: Display the netscaler partion list
ansible.builtin.debug:
var: partition_list
- name: get ns partition using command
ansible.builtin.command: "ssh username@ipaddress 'show partition default'"
register: cmd_result
- name: Display the show ns command result
debug:
var: cmd_result
------------------------------------------------------------------------
code2:
---
- name: Gather facts for lb
hosts: localhost
gather_facts: false
connection: local
collections:
- netscaler.adc
vars:
netscaler_url: "https://enter ip address/nitro/v1/config"
tasks:
# - name: Get all ssl certificates
# netscaler.adc.sislcertkey:
# nitro_user: enter username
# nitro_pass: enter password
# nsip: enter ip address
# validate_certs: false
# - name: get partition details
# netscaler.adc.nspartition:
# nitro_user: "enter username"
# nitro_pass: "enter password"
# nsip: "enter ip address"
# validate_certs: false
# state: present
# register: partition_list
- name: switch to default partitions
ansible.builtin.uri:
url: "{{ netscaler_url }}/nspartition"
#operation: post
method: GET
force_basic_auth: true
url_username: "enter username"
#nsip: enter pass
#nitro_user: " enter username"
#nitro_pass: "enter pass"
url_password: "enter pass"
validate_certs: false
#resource: nitro/v1/config/nspartition
headers:
Content-Type: "application/json"
#attributes:
#nspartition:
#partitionname: "default"
body:
nspartition:
partitionname: "default"
return_content: true
status_code: 200
body_format: json
register: partition_default
- name: Display the partition name
debug:
var: partition_default
- name: List all partitions
ansible.builtin.uri:
url: "{{ netscaler_url }}/nspartition"
method: GET
force_basic_auth: true
url_username: "enter username"
url_password: "enter pass"
validate_certs: false
headers:
Content-Type: "application/json"
return_content: true
register: partition_list
- name: Extract the partition namme
ansible.builtin.set_fact:
partition_name: "{{ partition_list.json.nspartition | map(attribute='partitionname') | list }}"
- name: Display the partition list cert content
debug:
var: partition_list
- name: Display the partition name
debug:
var: partition_name
- name: List ssl certkey details
ansible.builtin.uri:
url: "{{ netscaler_url }}/sslcertkey?view=summary"
method: GET
force_basic_auth: true
url_username: "enter username"
url_password: "enter pass"
validate_certs: false
headers:
Content-Type: "application/json"
return_content: true
register: ssl_list
- name: Display the ssl details cert content
debug:
var: ssl_list