Insert the following lines into the file. Once you've successfully connected to the host virtual machine, create and open a file named credentials: mkdir ~/.azure For security reasons, credential files should only be used in development environments.įor more information about defining Ansible credentials, see Providing Credentials to Azure Modules. In this section, you create a local credentials file to provide credentials to Ansible. Option 1: Create Ansible credentials file
Option 1: Create an Ansible credentials file.The service principal applicationID, and secretĬonfigure the Ansible credentials using one of the following techniques:.Your Azure subscription ID and tenant ID.To configure the Ansible credentials, you need the following information: However, Ansible 5.0.0 and ansible-core 2.12 will require 3.8 and newer. Ansible 4.0.0 and ansible-core 2.11 has a soft dependency on Python 3.8, but functions with lower versions. Ansible control node requires Python 2 (version 2.7) or Python 3 (versions 3.5 and higher) installed.
Sudo pip3 install -r requirements-azure.txt # Get required modules for Ansible on Azure list # Install Ansible az collection for interacting with Azure.Īnsible-galaxy collection install azure.azcollection Run the following commands to configure Ansible on Centos: #!/bin/bash # Install Ansible azure_rm module for interacting with Azure. # Update all packages that have available updates. Run the following commands to configure Ansible 2.9 on Centos: #!/bin/bash
Install Ansible on the virtual machine Ansible 2.9 with the azure_rm module ssh the with the appropriate value returned in previous commands. Using the SSH command, connect to your virtual machine's public IP address. (Get-AzVM -ResourceGroupName QuickstartAnsible-rg QuickstartAnsible-vm-pwsh | Get-AzPublicIpAddress).IpAddress Az vm show -d -g QuickstartAnsible-rg -n QuickstartAnsible-vm -query publicIps -o tsv