Skip to content

running ansible in centos docker container

Notifications You must be signed in to change notification settings

frozendark01/docker-ansible-centos

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 

Repository files navigation

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'