Ansible Configuration Templates for Moodle Workload Configuration Guides

Posted on

Moodle is a free open-source software e-learning platform. It is designed to be scalable and with the help of Kemp 360 Central, Kemp LoadMaster and Ansible, it is now easier than ever to configure and scale Moodle. Since the release of Kemp 360 Central 2.4, we now support configuration of centrally managed LoadMaster’s using Ansible. It is now possible to configure multiple LoadMasters, Virtual Services and Real Servers in one single Ansible playbook without having to access the LoadMaster user interface.

Getting Started

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’s Ansible modules from Kemp’s website

Kemp’s module can be found here: https://kemptechnologies.com/kemp360/ansible-module/Once extracted, you will have access to Kemp’s library modules, utility modules and example playbooks, including the Moodle playbook.

3. Configure Ansible to recognise Kemp’s modules

To successfully run any playbooks that are created using Kemp’s Ansible modules, we must first tell Ansible where Kemp’s modules are located. The easiest way to achieve this is to create an Ansible config file within the /ansiblepoc-master/ directory. Create a file called:

    ansible.cfg     

And add the following lines:

 [defaults]   

library = /home/path/to/kemp_ansible/library/   module_utils = 

/home/path/to/kemp_ansible/module_utils/       

To ensure Ansible uses the provided config file, Kemp’s playbooks must be run from within the /ansiblepoc-master/ directory and outside the /examples/ directory.

4. Configure Kemp’s Moodle playbook

To successfully run Kemp’s Moodle playbook, we need to provide some configuration values. The playbook moodlePlaybook.yml is located in the /examples/ directory. The settings within the playbook are based on both Kemp’s Moodle Template and the deployment guide that is available here: https://support.kemptechnologies.com/hc/en-us/articles/203123459-MoodleThe playbook has been configured to create a HTTPS Virtual Service with a HTTP Redirect and two Real Servers. It is also configured to upload and assign a certificate to the HTTPS Virtual Service. The settings that require values are described below:

central_address The IP address of the Kemp 360 Central that manages your LoadMaster.  
central_api_key Please refer to step 4 here: https://kemptechnologies.com/blog/how-to-use-ansible-to-automate-the-configuration-and-deployment-of-load-balancers/ to get the required Kemp 360 Central API key.  
lm_addressThe IP address of the LoadMaster where Virtual Services and Real Servers will be created.  
vs_ip The Virtual Service IP address.  
ssl_cert_path The path to where the certificate is located.
moodle_server_1 The IP address of the Real Server.
moodle_server_1_port The port of the Real Server.

The Moodle playbook can be easily modified to meet your needs, whether it is to add more Virtual Services (VS), VS settings or Real Servers. The available settings that can be used in our Ansible playbooks are available in the link provided below:

https://support.kemptechnologies.com/hc/en-us/articles/360035479011/

You can also check out other example playbooks in the /examples/ directory for more ideas.

5. Run Kemp’s Moodle playbook

Once we have added the necessary configuration values to the Moodle playbook, we can then run this playbook from the same directory as our Ansible config file. To run the playback, we execute the command:

ansible-playbook -vvv examples/moodlePlaybook.yml

Adding -vvv allows you to see information such as what settings were modified for each Virtual Service or Real Server configured in the playbook.As soon as the playbook has run successfully, your LoadMaster is now configured and ready to be used by Moodle. 

Moodle Playbook:

 name: Create a HTTPS service for Moodle
 hosts: localhost

 vars:
 central_address: ''
 central_username: 'Admin' # only Admin can execute ansible playbooks on Central
 central_api_key: ''
 lm_address: ''
 lm_port: '443'
 vs_ip: ''
 ssl_cert_path: ''
 moodle_server_1: ''
 moodle_server_1_port: ''
 moodle_server_2: ''
 moodle_server_2_port: ''
 tasks:
 name: Upload Certificate
 cert_management:
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 central_address: '{{ central_address }}'
 central_username: '{{ central_username }}'
 cert_name: 'cert_test'
 cert_file: '{{ ssl_cert_path }}'
 replace: 0
 intermediate: 0
 central_api_key: '{{ central_api_key }}'
 name: Create Virtual Service Moodle_HTTPS on LM
 virtual_service:
 central_address: '{{ central_address }}'
 central_username: '{{ central_username }}'
 central_api_key: '{{ central_api_key }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 enable: 'Y'
 nickname: 'Moodle_HTTPS'
 vs_ip: '{{ vs_ip }}'
 vs_port: 443
 vs_protocol: 'tcp'
 vs_type: 'http'
 transparent: 1
 subnet_originating: 0
 ssl_acceleration: 1
 cert_name: 'testcert'
 persist: 'super'
 check_port: 389
 tls_type:
 tls1.0
 tls1.1
 tls1.2
 tls1.3
 name: Create Virtual Service Moodle_HTTP on LM
 virtual_service:
 central_address: '{{ central_address }}'
 central_username: '{{ central_username }}'
 central_api_key: '{{ central_api_key }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 enable: 'Y'
 nickname: 'Moodle_HTTP'
 vs_ip: '{{ vs_ip }}'
 vs_port: 80
 vs_protocol: 'tcp'
 vs_type: 'http'
 error_code: 302
 error_url: 'https://%h%s'
 transparent: 0
 subnet_originating: 0
 name: Create Real Server 1
 real_server:
 central_address: '{{ central_address }}'
 username: '{{ central_username  }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 api_key: '{{ central_api_key }}'
 vs_ip: '{{ vs_ip }}'
 vs_port: 443
 vs_prot: 'tcp'
 rs_ip: '{{ moodle_server_1 }}'
 rs_port: '{{ moodle_server_1_port }}'
 rs_enable: 'Y'
 name: Create Real Server 2
 real_server:
 central_address: '{{ central_address }}'
 username: '{{ central_username  }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 api_key: '{{ central_api_key }}'
 vs_ip: '{{ vs_ip }}'
 vs_port: 443
 vs_prot: 'tcp'
 rs_ip: '{{ moodle_server_2 }}'
 rs_port: '{{ moodle_server_2_port }}'
 rs_enable: 'Y'
 check_port: 389
 tls_type:
 tls1.0
 tls1.1
 tls1.2
 tls1.3
 name: Create Virtual Service Moodle_HTTP on LM
 virtual_service:
 central_address: '{{ central_address }}'
 central_username: '{{ central_username }}'
 central_api_key: '{{ central_api_key }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 enable: 'Y'
 nickname: 'Moodle_HTTP'
 vs_ip: '{{ vs_ip }}'
 vs_port: 80
 vs_protocol: 'tcp'
 vs_type: 'http'
 error_code: 302
 error_url: 'https://%h%s'
 transparent: 0
 subnet_originating: 0
 name: Create Real Server 1
 real_server:
 central_address: '{{ central_address }}'
 username: '{{ central_username  }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 api_key: '{{ central_api_key }}'
 vs_ip: '{{ vs_ip }}'
 vs_port: 443
 vs_prot: 'tcp'
 rs_ip: '{{ moodle_server_1 }}'
 rs_port: '{{ moodle_server_1_port }}'
 rs_enable: 'Y'
 name: Create Real Server 2
 real_server:
 central_address: '{{ central_address }}'
 username: '{{ central_username  }}'
 lm_address: '{{ lm_address }}'
 lm_port: '{{ lm_port }}'
 api_key: '{{ central_api_key }}'
 vs_ip: '{{ vs_ip }}'
 vs_port: 443
 vs_prot: 'tcp'
 rs_ip: '{{ moodle_server_2 }}'
 rs_port: '{{ moodle_server_2_port }}'
 rs_enable: 'Y' 

To learn more, read our Optimizing AX for Remote Education Through Load Balancing blogpost here.

Posted on

Kemp Technologies

Kemp Technologies