Ansible is an open-source configuration and infrastructure management tool providing capability to implement infrastructure as code (IaC). Especially in Linux based implementations ansible is used heavily, however, it can support automation on Windows platform as well. Let’s learn some Linux IaC with ansible in the coming posts and in this post, lets try to setup an ansible installation on a Ubuntu 18.04 VM with python3 support, in Azure. Setting up user for ansible in the VM was explained in previous post “Create New Linux Admin User in Azure Ubuntu VM”.
First ensure your user has a password setup for sudo commands as the password will be prompted for when executing command with sudo in the Azure Ubuntu VM for the non-default user. If you have removed password using sudo passwd -d -l <username> for the ansible user as explained in article “Create New Linux Admin User in Azure Ubuntu VM”, set the password again for the user using sudo passwd <username> command by ssh to the VM with default user.
Then ssh to VM with the non-default user of the VM, in this case the ansibleuser (user name used for admin ansible).
Check current python version with python --version. Then do a sudo apt update to refresh repository list.
We need to install software-properties-common package to enable better control over package manager by using personal package archive (PPA) repositories.
sudo apt install software-properties-common
Let’s setup deadsnakes PPA which contains later versions of python for Ubuntu repositories than default.
sudo add-apt-repository ppa:deadsnakes/ppa
Confirm the prompt to continue by pressing enter key and finish the install.
Refresh the package lists with a sudo apt update. Now we can install python 3.8 with the below command.
sudo apt install python3.8
Let’s install pip (Pip Installs Packages) for python3 that we have setup.
sudo apt install python3-pip
Provide confirmation and continue with the installation.
Now we can check version of pip3 with pip3 --version. To upgrade to latest version of pip3 lets use the command below.
sudo pip3 install --upgrade pip
Now let’s install ansible with below command.
python3 -m pip install ansible
We can try running ansible and looks like we got the installation right. In next posts let’s explore ansible to understand how we can automate apps and IT infrastructure.
No comments:
Post a Comment