This article demonstrates how to configure your Kemp LoadMaster using Ansible playbooks.
Kemp’s Technical Preview Programs are designed to enable the generation of customer feedback and insights on our current and future products. Technical Previews are available to anyone interested in testing Kemp software and providing feedback to Product Management and Development teams.
Objective: Show you how to automate your Kemp LoadMaster configuration through the Ansible module and Kemp 360 Central integration.

Pre-requisites
- Linux VM, I´m using an Ubuntu VM in this case
- Kemp 360 Central
- Kemp LoadMaster
*Note: All this resources may be deployed on-premises or in Azure or any cloud provider supported by Kemp.
Steps to configure Kemp LoadMaster using Ansible Playbooks
SSH to your Linux VM, I´m using windows terminal to SSH to the Ubuntu VM
ssh your-user@your-vm-machine-ip-address

Install Ansible:
sudo apt-get install ansible

Then you will get prompted to type your password and confirm the additional disk space needed.

Now let´s install python http library with the following cmd:
sudo apt-get install python-requests

Now create a new directory on your Ubuntu VM, i.e. ~/home/bal/configuration
Access to folder
cd /home/bal/configuration

Now download the Kemp Ansible module on the Ubuntu machine
curl -o kemp-ansible-module https://kemptechnologies.com/files/assets/tools/kempansiblemodule.zip

Now unzip files, if you don´t have the unzip utility, you can install it by using:
sudo apt-get install unzip
Since file source and destination will be the same, you can use:
unzip kemp-ansible-module

Now list the directory:
ls

Access to the Kemp-Ansible directory, in this case:
cd /home/bal/configuration/Kemp-Ansible/

List the current directory, you should see a zip file and a pdf:

Now unzip the KempAnsibleModule.zip file
unzip KempAnsibleModule

At this point we have installed Ansible and downloaded the Kemp Ansible Module on the ubuntu VM. Now let´s setup the connection between these 2 components so that Ansible can find the Kemp Ansible Module to run the playbooks.
Let´s modify the Ansible profile using the cmd below
vi /etc/profile
*note: ensure that you do the following w/root permissions.
Go to the end of the file and add the following 2 lines:
export ANSIBLE_LIBRARY="/home/bal/configuration/kemp_ansible/library/"
export ANSIBLE_MODULE_UTILS="/home/bal/configuration/kemp_ansible/module_utils/"

save the file in Vim and quit the editor
- Press Esc
- Type “:wq”
- Press Enter
Now logout
logout

Log in again

Execute the cmd below
export
You should see the module added:

Now let´s edit the ansible hostfile to run the playbooks on the localhost:
sudo -i
vi /etc/ansible/hosts
Go to the end of the file and add
[localhost]
IP-address-of-your-machine

Then save and close the file.
Now let´s generate the ssh keys to allow ansible to run the playbooks. Execute the cmd below:
ssh-keygen
*Note: will use the default options. Empty passphrase. So”enter, enter”

Now install the keys using the cmd below:
ssh-copy-id -i ~/.ssh/id_rsa root@10.0.7.252

*Note: if you get an error: “ssh root@host – Permission denied, please try again” – do the following:
edit the /etc/ssh/sshd_config file using the cmd below:
nano /etc/ssh/sshd_config
replace the line starting with PermitRootLogin(if it exists) with PermitRootLogin yes
and then for the changes to take affect you will need to restart the ssh service
sudo service ssh restart
After a few seconds go back to your own terminal and attempt to login again
ssh root@[your.ip.address.here]
The API Key from Kemp 360 Central is required to authenticate and run the Ansible Playbooks. Copy the following command into the Ansible Server to obtain the API Key
curl -k -X POST -d '{"username":"Username","password":"Password"}' https://Kemp360CentralIPAddress/api/v1/user/authenticate/

*Note: Copy your API key and keep it handy
Now we can start working with the playbooks, go to the examples directory:
cd /home/bal/configuration/examples

You should see 2 files mediumConfig.yml and smallConfig.yml as shown below:

Let´s modify the smallConfig.yml file,
sudo vi smallConfig.yml

This file contains different sections:
- Where are we running this playbook – in this case localhost
- Variables related to the Kemp 360 Central
- Task that will be executed

Provide the Kemp 360 Central parameters:
- Kemp 360 Central IP Address
- Kemp 360 Central Username
- Kemp 360 Central API key
- LoadMaster Address and port
- IP address for the Virtual Service
- Port for the Virtual Service
- Protocol for the Virtual Service
- Real Server IP address

- name: Create a small configuration for LoadMaster
hosts: localhost
vars:
central_address: 10.0.7.59
central_username: admin
central_api_key: e4ce28d47796f6f98b18206afc62xxxxxxx
lm_address: 10.0.7.241:443
ip: 10.0.7.246
port: 443
prot: 'tcp'
rs_ip: 10.0.7.252
tasks:
- name: Create Virtual Service Pathos on LM
virtual_service:
central_address: '{{ central_address }}'
central_username: '{{ central_username }}'
central_api_key: '{{ central_api_key }}'
lm_address: '{{ lm_address }}'
enable: 'Y'
nickname: 'Pathos'
ip: '{{ ip }}'
port: '{{ port }}'
protocol: '{{ prot }}'
vs_type: 'http'
ssl_acceleration: 1
check_type: 'icmp'
qos: 'Maximize-Reliability'
transparent: 1
- name: Create 10 real servers in sequence
real_server:
central_address: '{{ central_address }}'
username: '{{ central_username }}'
lm_address: '{{ lm_address }}'
api_key: '{{ central_api_key }}'
vs_ip: '{{ ip }}'
vs_port: '{{ port }}'
vs_prot: '{{ prot }}'
rs_ip: '{{ rs_ip }}'
rs_port: '{{ item }}'
with_sequence: start=8000 end=8010 format='%d'
Now save and close:
“:wq”
Now proceed to run the playbook:
ansible-playbook smallConfig.yml

You can go now to your Kemp 360 Central and you should be able to see the new configuration:

Now you can configure your own playbooks to configure your Kemp LoadMaster. You can check the full Ansible reference here: https://kemptechnologies.com/files/assets/documentation/kemp360/central/Reference_Guide-Kemp_Modules_for_Ansible.pdf?pdf-file-view=1
One Reply to “Configure your Kemp LoadMaster using Ansible Playbooks”