Orchestrating Azure Resources with Ansible

Introduction

Infrastructure and Configuration Architecture

Steps

ansible-playbook azure_ansible.yaml --extra-vars "resource_group_name=myrsg subscription_id=ABC123 tenant_id=DEF456 contributor_roleid=b24988ac-6180-42a0-ab88-20f7382dd24c msi_name=mymsi vnet_name=myvnet subnet1_name=mysbt1 subnet2_name=mysbt2 dns_name=hynes.pri cluster_name=mycluster location=westeurope vm_username=myuser vm_password=MyPass98+332711"
- name: Sleep for 30 seconds to make sure Msi created
wait_for:
timeout: 30
delegate_to: localhost
- name: Link private dns to vnet
azure_rm_resource:
api_version: '2018-09-01'
resource_group: "{{ resource_group_name }}"
provider: network
resource_type: privatednszones
resource_name: "{{ dns_name}}"
subresource:
- type: virtualnetworklinks
name: link1
body:
location: Global
properties:
virtualNetwork:
id: "/subscriptions/{{ subscription_id }}/resourceGroups/{{ resource_group_name }}/providers/Microsoft.Network/virtualNetworks/{{ vnet_name }}"
registrationEnabled: false
- name: Get VMScaleSet info
azure_rm_resource_info:
resource_group: "{{ nodersggroup.response[0].properties.nodeResourceGroup }}"
provider: compute
resource_type: virtualmachinescalesets
api_version: "2017-12-01"
register: vmssresources
until: vmssresources.response[0].name is defined
retries: 20
delay: 60

Conclusion

Resources

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Adrian Hynes

Adrian Hynes

48 Followers

Cloud Platform Architect. Opinions and articles on medium are my own.