Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Configure your Kemp LoadMaster using Ansible Playbooks

3 min read

kemp-ansible-module

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 
01-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Install Ansible:  

sudo apt-get install ansible
02-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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

03-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Now let´s install python http library with the following cmd:

sudo apt-get install python-requests
04-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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

Access to folder

cd /home/bal/configuration
05-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Now download the Kemp Ansible module on the Ubuntu machine

curl -o kemp-ansible-module https://kemptechnologies.com/files/assets/tools/kempansiblemodule.zip
06-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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
07-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Now list the directory:

ls
08-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Access to the Kemp-Ansible directory, in this case:

cd /home/bal/configuration/Kemp-Ansible/
09-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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

010-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Now unzip the KempAnsibleModule.zip file

unzip KempAnsibleModule
011-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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/"
012-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

save the file in Vim and quit the editor

  1. Press Esc
  2. Type “:wq”
  3. Press Enter

Now logout

logout
013-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Log in again

014-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Execute the cmd below

export

You should see the module added:

015-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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
016-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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”

017-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Now install the keys using the cmd below:

ssh-copy-id -i ~/.ssh/id_rsa root@10.0.7.252
018-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

*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/
019-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

*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
020-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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

021-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

Let´s modify the smallConfig.yml file,

sudo vi smallConfig.yml
022-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

This file contains different sections:

  1. Where are we running this playbook – in this case localhost
  2. Variables related to the Kemp 360 Central
  3. Task that will be executed
023-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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
024-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure
	- 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
025-Configure-Kemp-LoadMaster-using-Ansible-Playbooks-wikiazure

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

Dave Rendón Microsoft Azure MVP, embracing and fostering tech intensity to benefit society and thrive in a digital world.

Leave a Reply

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