Hopp over navigasjon

Ansible Playbooks for Azure

This repository contains examples and best practices for building Ansible Playbooks for Azure.


  • Azure Account. If you don't have it, get a free one.

To authenticate with Azure, generate service principal and expose them as environment variables or store them as a file.

  • Install Ansible)
  • Install Azure dependencies pacakage pip install ansible[azure]
  • Install azure_preview_modules role.
  • Install azure_preview_module role's dependencies packages. pip install -r ~/.ansible/roles/Azure.azure_preview_modules/files/requirements-azure.txt

How to run

To run samples in your local environment,

  • git clone https://github.com/Azure-Samples/ansible-playbooks.git
  • cd ansible-playbooks
  • modify playbook to replace variables with yours, such as resource group name.
  • add Azure credential info either by setting environment variables or by credential files or by AZ CLI login. ``` # option 1. setting below environment variables AZURE_CLIENT_ID= AZURE_SECRET= AZURE_SUBSCRIPTION_ID= AZURE_TENANT=

# option 2. add below content to file $HOME/.azure/credentials. [default] subscription_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx client_id=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx secret=xxxxxxxxxxxxxxxxx tenant=xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx

# option3. do az login firstly az login ``` - ansible-playbook sample.yml

You also could develop your Ansible playbook and run it in Visual Sutdio Code.

How to Contribute

Please refer to Coding Guideline on how to contribute.


Ansible on Azure

Get Started with Azure

Ansible Playbook

Ansible role azure_preview_modules

Ansible Galaxy for example roles from the Ansible community for deploying many popular applications.


MIT License

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.microsoft.com.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.


Sample playbooks in this repository are tested via travis CI, please see detail CI plan.