Ansible Playbooks
Ansible playbooks allow you to direct Ansible to configure your environment. Playbooks are coded using YAML so as to be human-readable.
To configure Azure credentials, you need the following information:
- Your Azure subscription ID and tenant ID
- The service principal application ID and secret
Pre-requisites:
- Azure account subscription, click here if you don't have one.
- Azure CLI needs to be installed.
- Service principal to create any resources in Azure cloud using Azure cloud shell or Azure CLI
Login to Azure
Enter Microsoft credentials
Create Azure Service Principal
Create a simple playbook to create resource group in Azure and also a Azure App Service. Make sure you modify the name of the resource group, Azure WebApp and location below.
Login to Azure Devops --> https://dev.azure.com
Select project dashboard.
Go to Pipelines -> New pipeline --> Click on Azure Repos Git or any SCM where you have playbooks stored. Select repo, click on Starter pipeline.
- Install Ansible on build agent
- Install Ansible rm module on build agent
- Execute Ansible playbook for creating resource group in Azure cloud.
- name: Delete Azure App Service
hosts: localhost
connection: local
vars:
resource_group: myResourceGroup
webapp_name: myfirstAwesomeWebApp
tasks:
- name:
azure_rm_webapp:
name: "{{ webapp_name }}"
resource_group: "{{ resource_group }}"
state: absent