The goal is to provision one or more web server instances behind a load balancer on any cloud provider automatically. See the following image for an example on Azure.
Follow these steps to provision the Web Server(s).
- Create a Project for this repo (
https://github.com/nleiva/ansible-web-server). I called the ProjectAzure WebServerin the example below.
- Create a Microsoft Azure Resource Manager credential with your Azure service principal parameters.
- The number and operating system of the backend servers are defined via the variable
vms. Its default value is defined in the vms file. It lists 2 instances; one runningcentos, and the other oneubuntu(these are the two distributions supported at the moment). You can override this with a newvmsdefinition as an Extra Variable.
vms:
1: centos
2: ubuntu- Put all these pieces together in a Job Template pointing to main.yml.
- Run the Job Template.
It should look like this when it finishes:
We distribute the traffic among the instances using an Azure Load Balancer to prevent failure in case any of the virtual machines fail. By default the web server is at http://testbed.eastus.cloudapp.azure.com/. You can modify this with the variable prefix. Its default value is testbed.
This URL will take you to one of the backend VM's. For example:
You can create a similar Job Template pointing to main.yml and pass an extra-var delete=true.
And run it.
You can alternatively run this with ansible-navigator.
pip3 install 'ansible-navigator[ansible-core]'ansible-navigator run main.ymlansible-navigator run main.yml -e cloud=aws -e dns_zone=sandbox760.opentlc.comansible-navigator run main.yml -e delete=trueNote: I use podman as my container engine (container-engine). You can change to another alternative in the ansible navigator config file.
Check ansible_core.










