Test Azure provisioning using Ansible and the web-based UI called AWX (the Open Source version of Ansible Tower):
AWX provides a web-based user interface, REST API, and task engine built on top of Ansible. It is the upstream project for Tower, a commercial derivative of AWX.
These tools are used to build a local Ansible Control VM using a CentOS 7.6:
- VirtualBox
- Vagrant
- Docker
- Ansible
- Ansible AWX
Once the Azure CentOS Linux VM Job Template is run within AWX, these resources will be deployed to Azure:
- A resource group
- A virtual network
- A Public IP address
- A Network security group that allows SSH
- A Network interface card
- A Storage account
- A CentOS VM
Before you can build the local Ansible Control VM, you will need to do the following steps first:
- Open an elevated PowerShell prompt.
- Install Chocolatey:
Set-ExecutionPolicy Bypass -Scope Process -Force; iex ((New-Object System.Net.WebClient).DownloadString('https://chocolatey.org/install.ps1'))
- Install VirtualBox:
choco install -y virtualbox - Install Vagrant:
choco install -y vagrant - Create an Azure Service Principal
and note down the
SUBSCRIPTION ID,CLIENT ID,CLIENT SECRET, andTENANT IDvalues for later use.
- Clone this repo to your local computer:
git clone git@github.com:adamrushuk/ansible-azure.git
- Update your Azure Service Principal credentials in
azure_ansible_credentials.yml:# Overwrite these example values below subscription: "aaaa1111-bbbb-cccc-abcd-aaabbbcccddd" client: "abcd1234-abcd-efff-1234-abcd12345678" secret: "MyStrongPassw0rd!" tenant: "12345678-ab12-cd34-ef56-1234abcd5678"
- Start the build from the root folder of the cloned repo:
vagrant up
- Open a browser and navigate to the AWX login page http://192.168.10.20.
- Log in to AWX using the default username
adminand default passwordpassword.
- Navigate to the Templates page, within the Resources menu.
- Click on the Template called
Azure CentOS Linux VM. - Ensure there are values entered for
INVENTORY,PROJECT,PLAYBOOK, andCREDENTIALas shown below:
- Navigate to the Templates page, within the Resources menu.
- Click on the rocket icon to start the
Azure CentOS Linux VMJob Template:
- The
JOBSscreen should then automatically open, where you can monitor the job progress:
- Navigate to the Azure Portal.
- Ensure you have a Resource Group called
centos-rgwith the following resources: