Overview
Ansible is an IT automation tool. It can configure systems, deploy software, and orchestrate more advanced IT tasks such as continuous deployments or zero downtime rolling updates. Ansible can be used to provision Azure resources.
From our partners:
Prerequisites
- Ubuntu 18.04
- Ansible has been installed. See here on how to install.
- Python has been installed. By default Python 2.x is installed on Ubuntu 18.04.
- (Optional) Azure account for verification and testing.
Installation
01. Install the pip library for Ansible-Azure
$ pip install ansible[azure]
02. Install the Azure Preview Module
$ ansible-galaxy install azure.azure_preview_modules
03. Install the Azure Preview Module dependencies
$ pip install -r ~/.ansible/roles/azure.azure_preview_modules/files/requirements-azure.txt
Configuration
04. Update the Azure credentials on the OS user level. Create the directory for the credentials if not yet existing.
$ mkdir ~/.azure
05. Create the credentials file/configuration.
$ nano ~/.azure/credentials
06. Set the content as follows. To retrieve the Subscription ID, Client ID, Secret Key and Tenant ID, refer to this guide.
[default] subscription_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx secret=xxxxxxxxxxxxxxxxx tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
Testing
07. Create a sample Ansible Playbook that creates a new Resource Group.
$ nano resource_group_create.yml
08. Set the content as follows
--- - name: Azure - Resource Group - Create hosts: localhost connection: local vars: resource_group: "rg-geek" location: southeastasia tasks: - name: Create a resource group azure_rm_resourcegroup: name: "{{ resource_group }}" location: "{{ location }}" ...
09. Run the Playbook
$ ansible-playbook resource_group_create.yml
10. Wait until the Playbook has completed its execution. The “Play Recap” section contains a summary of the resources created and updated.
For enquiries, product placements, sponsorships, and collaborations, connect with us at [email protected]. We'd love to hear from you!
Our humans need coffee too! Your support is highly appreciated, thank you!