Creating a Netscaler VIP using ansible

Creating a content-switched vip on a Netscaler is pretty easy but you need to complete the steps of creating the server, services, lb vserver, cs vserver.
If you need to create more than 1 vip it will take some time to do this manually and it could also be error prone.

Automation is your friend in this situation and in this project i used ansible. This project/script was written to create content-switched VIP , but it can also create a lb vserver VIP if you don’t use content-switching. It can also be used to remove it. It can also be used to add/remove a server to a vip that was already created. You can do this using a combination of modules tags and the state of each part of the vip.

Usage:

In the vars file (group_vars/localVPX/vars) you have to define your tla name and the ip of th vip, the service type of the vip and the port , the server ip’s.
When you run it you also need to specify the state(present/absent) of each part of the vip. Using absent you can remove any part of thw vip. You can also remove the whole vip if you want.
The process of creating a vip needs 2 steps. So you need the run the script twice. This is because in the first step using a jinja template a svg file is created and used in the step2 for binding the services to the lb vserver.
So step1 creates everything , but it can not bind the services to the lb vserver. Step2 it binds the services to the lb vserver.
You can also remove the vip. This is also a 2 step process as you need to remove the cs vserver first (step1) and then you can remove all the other parts.

Examples:

you create a whole vip like this:

Step1 : ansible-playbook -i inventory create_cs.yml -e "server_state=present service_state=present lb_state=present cs_state=present" --skip-tags bindservices
Step2 : ansible-playbook -i inventory create_cs.yml -e "server_state=present service_state=present lb_state=present cs_state=present" --tags bindservices

you can also remove the vip like this:


Step1 : ansible-playbook -i inventory create_cs.yml -e "server_state=present service_state=present lb_state=present cs_state=absent" --skip-tags bindservices
Step2 : ansible-playbook -i inventory create_cs.yml -e "server_state=absent service_state=absent lb_state=absent cs_state=absent" --skip-tags bindservices

Here you can find the files for this project:
https://github.com/czirakim/create-netscaler-vip


About the author

Mihai is a Network Aficionado with more than 10 years experience

Leave a Reply

Your email address will not be published. Required fields are marked *