/docker-ansible-centos

running ansible in centos docker container

Primary LanguageDockerfile

Ansible running in a Docker container - Azure

Create an Azure Service Principal =>

az ad sp create-for-rbac --name  \
        --role Contributor \
        --scopes /subscriptions/
        
   Replace  with your service principal name.     
        

Build the Docker image used to run Ansible

docker build . -t ansible

Start the Ansible container.

docker run -it ansible 
run => ansible --version

Connect to Azure from the Ansible container.

Assign the following environment variables to connect to Azure:

export AZURE_TENANT=""
export AZURE_SUBSCRIPTION_ID=""
export AZURE_CLIENT_ID=""
export AZURE_SECRET=""

Test Ansible connection - Run the following Ansible command to create a resource group:

ansible localhost -m azure_rm_resourcegroup -a 'name=myResourceGroup location=eastus'