Manage Azure virtual machines with Ansible Tower

Moving your IaaS infrastructure to Azure does not mean that you have done with servers maintenance and management.There are a lot of tools that you can use to deploy your configurations and Ansible is one of the most powerful.

Ansible has the three following characteristics that i like most:

  • Agent-less – The only thing that you need is to enable winrm on windows and ssh for linux .
  • Multi-platform – Ansible contain modules for all the known platforms like azure,aws,linux,windows etc
  • Open Source

Ansible works with yaml files that include the task that you want to execute.A playbook can be a set of tasks that can run at once.

We will see with a simple example how we can deploy ansible tower and start managing our IaaS infrastructure at a very short time.

I did not write a tutorial, it is just a small deployment that i have made.

What you will need:

  • Azure Subscription
  • Ansible Tower Virtual Machine
  • Windows or Linux virtual machine to test
  • Azure Virtual Network with at least two subnets

Azure Subscription

You can create an Azure Subscription for free here .

Virtual Machine that runs Ansible Tower

You will need a linux virtual machine to deploy Ansbile tower. In our example i have used the ansible tower redhat image from Azure Marketplace.If you go with this deployment you will need a redhat ansible tower license.You can request one trial license for free but only for evaluation purposes from here .

Windows or Linux virtual machine to test

You will need to deploy a windows or linux virtual machine in order to make a little test for our deployment.I have used a windows server 2016 virtual machine from azure marketplace.

Azure Virtual Network with at least two subnets

You will need to deploy an Azure virtual network with at least two subnets, one for Ansible tower and another one for the hosts.

At the end of the deployment you will be able to login at your Ansible tower with it’s public ip.

Ansible Tower Web Interface

As you can see i have done a lot of failed jobs until i understand how it is working.I have done a major mistake at virtual networks and there was no communication between the tower and the virtual machine .

Deploy your first playbook

The minimum things that you have to do to deploy your first playbook are :

  • Inventory – You have to declare your connection variables and Hosts.
  • Project – You have to create a project that contains your playbook code and yes you can use Git to provide the code!
  • Credentials – You have to specify every credential for your deployment ( host and github for our example )
  • Templates – You have to create a template that contains all the information above and run it.

Here you can see an image form my template

No alt text provided for this image

So when i click launch it will connect to the windows server with Winrm using the variables and the credentials that i have provide and it will execute my playbook.

My playbook contains a very simple command to start the windows print spooler service.Obviously you can write a set of tasks in your playbook and you can also specify the order that the tasks will execute.

You can find the specific playbook at my github repository here.

I will close this small article with a very sort video of the deployment

My task was very simple.But imagine what would you do if you had 10,100 or 1000 hosts.Even the most simple task can take you a lot of time to be completed without management tools.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: