HashiCorp Terraform is an infrastructure-as-code software tool used to orchestrate and manage IT infrastructure, including networking. Terraform codifies infrastructure into declarative configuration files for easier provisioning, compliance, and management. NetScaler Terraform provider allows users to configure NetScaler's for various use-cases such as global server load balancing, SSL offloading, web application firewall policies, and more. With Terraform, you can share and reuse your NetScaler configurations across your environments — a key time saver when migrating applications from your data center to any public cloud.
In this tutorial, we will go through Terraform installation and configure our first basic use-case of setting up load balancing vserver on NetScaler:
Pre-requisite : NetScaler is installed, its NSIP, VIP and SNIP configured and ready to receive user traffic.
- Install Terraform
- Download Terraform NetScaler examples
git clone https://github.com/citrix/terraform-provider-citrixadc/
- Define a Netscaler Terraform provider details
Navigate with the above repo to simple_server example folder :
cd …/terraform-provider-citrixadc/examples/lb/simple_lb$
terraform { required_providers { citrixadc = { source = "citrix/citrixadc" } }}provider "citrixadc" { endpoint = "http://10.1.1.3:80" username = "UsernameOfYourADC" password = "PasswordOfYourADC" }
- Define your Netscaler configurations declaratively
resource "citrixadc_lbvserver" "production_lb" { name = "terraform_LB" ipv46 = var.vip_config["vip"] port = "80" servicetype = "HTTP"}resource "citrixadc_servicegroup" "backend" { servicegroupname = "productionBackend" lbvservers = [citrixadc_lbvserver.production_lb.name] servicetype = "HTTP" clttimeout = var.backend_service_config["clttimeout"] servicegroupmembers = formatlist( "%s:%s", var.backend_services, var.backend_service_config["backend_port"], )}
- Provide values to Netscaler configurations
vip_config = { vip = "10.105.158.176"}backend_service_config = { clttimeout = 40 backend_port = 80}backend_services = [ "10.105.158.177", "10.105.158.178",]
- Run Terraform commands to apply configuration to target NetScaler:
terraform init
To view the changes that will be done to your NetScaler configurations, run
terraform plan
You will see diff between the NetScaler config specified and the existing NetScaler config for that resources, thuis showing the resources that will wither created or updated to achieve the desired NetScaler configuration.
Now, to apply the configurations run
terraform apply
Review the configuration changes proposed by Terraform and type yes to approve :
That’s it! You can log in to NetScaler manually and validate the configuration changes made by Terraform.
Once your backend services are up, your Loadbalancing vserver terraform_LB State will show up and it will be ready to receive user traffic and load balance it across your app services. Similarly
terraform destroy
Recommended Comments
There are no comments to display.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now