Created
June 8, 2020 15:40
-
-
Save russmckendrick/ab3c930925873d4eaae75d392bbad658 to your computer and use it in GitHub Desktop.
AzureDevOpsAnsiblePipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
trigger: | |
- master | |
pool: | |
vmImage: 'ubuntu-latest' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
steps: | |
- task: UsePythonVersion@0 | |
displayName: 'Install Python' | |
inputs: | |
versionSpec: '3.6' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- task: AzureCLI@2 | |
displayName: 'Azure CLI' | |
inputs: | |
azureSubscription: '$(SUBSCRIPTION_NAME)' | |
addSpnToEnvironment: true | |
scriptType: 'bash' | |
scriptLocation: 'inlineScript' | |
inlineScript: | | |
echo "##vso[task.setvariable variable=ARM_SUBSCRIPTION_ID]$(az account show --query="id" -o tsv)" | |
echo "##vso[task.setvariable variable=ARM_CLIENT_ID]${servicePrincipalId}" | |
echo "##vso[task.setvariable variable=ARM_CLIENT_SECRET]${servicePrincipalKey}" | |
echo "##vso[task.setvariable variable=ARM_TENANT_ID]${tenantId}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "##vso[task.setvariable variable=ARM_SUBSCRIPTION_ID]$(az account show --query="id" -o tsv)" | |
echo "##vso[task.setvariable variable=ARM_CLIENT_ID]${servicePrincipalId}" | |
echo "##vso[task.setvariable variable=ARM_CLIENT_SECRET]${servicePrincipalKey}" | |
echo "##vso[task.setvariable variable=ARM_TENANT_ID]${tenantId}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- script: pip install ansible[azure] | |
displayName: 'Install Ansible and the Azure modules' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- script: ansible-playbook -i inv site.yml | |
displayName: 'Run Ansible Playbook' | |
env: | |
AZURE_CLIENT_ID: $(ARM_CLIENT_ID) | |
AZURE_SECRET: $(ARM_CLIENT_SECRET) | |
AZURE_TENANT: $(ARM_TENANT_ID) | |
AZURE_SUBSCRIPTION_ID: $(ARM_SUBSCRIPTION_ID) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment