Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save rdtechie/ba690c90a20487dbbc9a793975c5c0fb to your computer and use it in GitHub Desktop.
Save rdtechie/ba690c90a20487dbbc9a793975c5c0fb to your computer and use it in GitHub Desktop.

How To Install Ansible and Azure Preview Modules on Ubuntu 18.04

This little guide explains the way how to install Ansible and the Azure Preview Modules in a virtualenv on Ubuntu 18.04. It also makes use of a wrapper for virtualenv, to make it easier to use virtualenv.

Prerequisites

sudo apt-get update
sudo apt-get install -y software-properties-common
sudo apt-get install -y python-setuptools python-dev libffi-dev libssl-dev git sshpass tree
sudo apt-get install python-pip
sudo -H pip install cryptography

Install and Configure virtualenv

sudo -H pip uninstall virtualenv
sudo -H pip uninstall virtualenvwrapper
sudo -H pip install virtualenv
sudo -H pip install virtualenvwrapper
sudo -H pip install httplib2
mkdir ~/.virtualenvs
mkdir ~/ansible_virtualenvs

Profile path

echo "source "$(which virtualenvwrapper.sh) >> ~/.profile
echo "export WORKON_HOME=~/.virtualenvs" >> ~/.profile
source ~/.profile

Install and Configure Ansible & Azure virtualenvs profiles

cd ~/ansible_virtualenvs
mkdir 2.6.0
cd 2.6.0
mkvirtualenv ansible-2.6.0
pip install ansible==2.6.0
pip install ansible[azure] --upgrade # Install Azure SDK
ansible-galaxy install Azure.azure_preview_modules # Install the Azure Preview azure_preview_modules
pip install -r ~/.ansible/roles/Azure.azure_preview_modules/files/requirements-azure.txt # Update Azure SDK

ansible --version
deactivate

How it Works

workon ansible-2.6.0
ansible --version

Azure SPN

Then when working with the AzureRM module for Ansible, you will need a SPN. Documentation here: https://docs.microsoft.com/en-us/cli/azure/create-an-azure-service-principal-azure-cli?view=azure-cli-latest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment