Ansible is an opensource toolset (available from ansible.com) that automates the deployment and configuration of application and networking resources. It makes use of playbooks that define the resource configurations through modules that are vendor provided or included in the core Ansible toolset.
To support customers that wish to automate configuration and deployment of application delivery resources, Kemp have developed Ansible modules for our LoadMaster load balancer platforms which are available for download from the kemp.ax website along with our Ansible Module Guide.
In this short post we will give an overview of the architecture, how to use the Kemp Ansible modules and show an example playbook.
Kemp enable Ansible automation through Kemp 360 Central, our centralized management solution, as this simplifies authentication (no need to maintain credentials for all the load balancers) and validation for configurations before deployment. Any LoadMaster load balancer under management by Kemp 360 Central can be configured using Ansible.
With Kemp Ansible automation, all playbooks are executed against Kemp 360 Central which validates and applies the configurations to the LoadMaster instances.
The use cases for Ansible automation are wide and varied. Development teams can automate deployment of applications across development, test and production systems to ensure consistency and reduce the effort and time required to update or deploy an application. IT Operations can provision load balancing resources with tried and tested configurations alongside other application resources such as servers and networking.
Getting Started
In Kemp 360 Central 2.4, we are supporting configuration of LoadMaster instances under management using Ansible. In this blog, I’ll give a quick run through how the Ansible module is configured and used to configure LoadMaster settings. You need to have at least one LoadMaster managed by your Kemp 360 Central instance as your Ansible target host.
1. Install Ansible Follow the installation guide at https://docs.ansible.com/ansible/latest/installation_guide/intro_installation.html.
2. Download and extract the kemp-ansible module from Kemp’s website athttps://kemptechnologies.com/kemp360/ansible-module/ Extract this module to somewhere on your system, like /home/configuration/ The Kemp Ansible module reference guide is available at https://support.kemptechnologies.com/hc/en-us/articles/360035479011/
3. In order to use the Kemp Ansible module, we must let Ansible know where it is.In the ~/configuration/kemp_ansible/library directory, run the command to set the environment variable
EXPORT ANSIBLE_LIBRARY=.
And in the ~/configuration/kemp_ansible/module_utils directory, run the command to set the environment variable
EXPORT ANSIBLE_MODULE_UTILS=.
This will instruct Ansible where to find the necessary module files for each component of a Kemp LoadMaster to use in its playbooks.
4. Example configurationsExample LoadMaster configurations can be found under ~/configuration/examples. In order to authenticate ourselves with Kemp 360 Central to use the configuration APIs, we must set the central_username and central_api_key variables in the playbook. The easiest way is to make an authentication request to Kemp 360 Central using curl
curl "https://{CENTRAL}/api/v1/user/authenticate/"--data"{""username"":""admin"",""password"":""{PASSWORD}""}"
And you will receive response:
{ "apikey": "abc123", "id": 1, "success": true }
Now that we have authentication credentials for Central, we can edit the example configurations to match our requirements.In the smallConfig.yml playbook, we can set the following variables (Filling in necessary values from your own environment):
central_address: '{CENTRAL_ADDR}' central_username: '{USER}' central_api_key: '{API_KEY}' lm_address: '{LOADMASTER_IP_PORT}' ip: '{VIRTUAL_SERVICE_IP_PORT}' port: 443 prot: 'tcp' rs_ip: '{REALSERVER_IP_PORT}'
5. Configuring a Virtual Service.With all mandatory fields set in order for Kemp 360 Central to know which LoadMaster we wish to configure, we can go and add any extra parameters we like to the virtual_service module. Please refer to the Kemp Ansible documentation for a list of all available modules, their parameters, and their types. For this example, we will leave the settings as is, which will configure a single http Virtual Service with SSL Acceleration, ICMP health checks, Transparency and the Maximize Reliability Quality of Service settings. The real_server module will configure 10 Real Servers in sequence which are differentiated by their port number, set as rs_port in the real_server module. This is achieved using Ansible’s imperative syntax “with_sequence” which modifies the {{item}} value we are setting as rs_port. Please refer to the Ansible documentation to see more examples of its imperative syntax.
6. Running a playbook: In the same directory as our playbook, we can now tell Ansible to run, and execute the steps to configure our LoadMaster. Run the command:
ansible-playbook "../path/to/examples/directory/mediumConfig.yml"
to execute the steps needed to configure the LoadMaster. If all goes well, we can now navigate to our LoadMaster UI, and see our configuration in place.