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.
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
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
echo "source "$(which virtualenvwrapper.sh) >> ~/.profile
echo "export WORKON_HOME=~/.virtualenvs" >> ~/.profile
source ~/.profile
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
workon ansible-2.6.0
ansible --version
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