Creating Azure Virtual Machine using ARM Template via Ansible Tower

OrionLab
2 min readApr 10, 2021

Ansible Playbook

Note: Replace template.json & parameter.json with location of each file. You can save them in GitHub, Azure Repos, any Storage Accounts like Azure Blob, Amazon S3 etc.

---
- hosts: localhost
become_user: awx
vars:
resource_group: sampleresourcegroup-rg
location: westus2
tasks:
- name: Creating Virtual Machine
azure_rm_deployment:
resource_group: "{{ resource_group }}"
location: westus2
name: devus3apo01
template: "{{ lookup('file', 'template.json') }}"
parameters: "{{ (lookup('file', 'parameter.json') | from_json).parameters }}"

Define resource_group and location in Ansible Tower Extra Variables Section with your specific.

Ansible Tower

Ansible Tower — Create Azure Virtual machine

Create Job Template, add -

1. Name,
2. description,
3. Job Type- Run,
4. Inventory — inventory01,
5. Project — Project Name,
6. choose Playbook — Virtual Machines/create_virtual_machine.yml,
7. Credentials — Microsoft Azure Resource Manager Key
8. Forks — 0
9. Limit — <Empty>
10. Verbosity — 0 (Normal)
11. Job Tags — <Empty>
12. Skip Tags — <Empty>
13. Labels — <Empty>
14. Instance Groups — <Empty>
15. Job Slicing — <Empty>
16. Timeout — <Empty>
17. Show Changes — Off
18. Options — Enable Privilege Escalation

Ansible Tower — Click on Save & launch to run the Template

Click on SAVE and then when page will refresh Launch Button will be Enabled, Click on LAUNCH.

This Article has been published by OrionLab.io

OrionLab.IO

--

--

OrionLab

Orionlab is a professional services company, Experts in Cloud Adoption Strategy Designing and Automation with their patented revolutionary tool — Cloudhive