Menu

Virtual Geek

Tales from real IT system administrators world and non-production environment

How to install and configure Ansible on Ubuntu

This is a step by step installation and configuration procedure of ansible on Ubuntu. Ansible is an open source IT automation mechanism that programs provisioning, configuration management, application deployment, orchestration, and many other IT processes. I have my Ubuntu server already setup and configured. Before installation first step I am doing is updating and upgrading Ubuntu server and OS packages using apt-get.

Redhat Ansible ubuntu sudo su - sudo apt-get update apt upgrade install ansible declarative imperative azure plugin module.png

Check this article: Get Started: Configure Ansible for Azure Cloud Infrastructure

root@ansible:~# sudo su -
root@ansible:~#
root@ansible:~# sudo apt-get update && sudo apt-get upgrade
Hit:1 http://us.archive.ubuntu.com/ubuntu focal InRelease
Hit:2 http://us.archive.ubuntu.com/ubuntu focal-updates InRelease
Hit:3 http://us.archive.ubuntu.com/ubuntu focal-backports InRelease
Hit:4 http://security.ubuntu.com/ubuntu focal-security InRelease
Reading package lists... Done
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages have been kept back:
  fwupd gnome-shell-extension-desktop-icons libegl-mesa0 libfwupd2 libfwupdplugin1 libgbm1 libgl1-mesa-dri libglapi-mesa
  libglx-mesa0 libjavascriptcoregtk-4.0-18 libwebkit2gtk-4.0-37 libxatracker2 linux-generic-hwe-20.04
  linux-headers-generic-hwe-20.04 linux-image-generic-hwe-20.04 mesa-vulkan-drivers ubuntu-advantage-tools
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
root@ansible:~#

Next install python3-pip package using apt-get command.

Redhat ansible controller adapter tower awx sudo apt-get install -y python3-pip python package test playbook configuration.png

root@ansible:~# sudo apt-get install -y python3-pip
Reading package lists... Done
Building dependency tree
Reading state information... Done
python3-pip is already the newest version (20.0.2-5ubuntu1.6).
0 upgraded, 0 newly installed, 0 to remove and 17 not upgraded.
root@ansible:~#

If you already have pip3 install make sure you upgrade it first before installing ansible.

redhat ubuntu linux ansible sudo pip3 install --upgrade pip download wheel python vcsa vmware esxi tower awx azure module plugin.png

root@ansible:~# sudo pip3 install --upgrade pip
Collecting pip
  Downloading pip-22.0.4-py3-none-any.whl (2.1 MB)
     |████████████████████████████████| 2.1 MB 16.2 MB/s
Installing collected packages: pip
  Attempting uninstall: pip
    Found existing installation: pip 20.0.2
    Not uninstalling pip at /usr/lib/python3/dist-packages, outside environment /usr
    Can't uninstall 'pip'. No files were found to uninstall.
Successfully installed pip-22.0.4
root@ansible:~#

This is the main command to install ansible using pip3 program.

Microsoft ansible redhat ubuntu pip3 install ansible metadata ansible-core tar gz wheels python3 markupsafe jinja2 pyparsing packaging.png

root@ansible:~# pip3 install ansible
Collecting ansible
  Downloading ansible-5.5.0.tar.gz (42.0 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 42.0/42.0 MB 30.3 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Collecting ansible-core~=2.12.3
  Downloading ansible-core-2.12.3.tar.gz (7.8 MB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 7.8/7.8 MB 51.5 MB/s eta 0:00:00
  Preparing metadata (setup.py) ... done
Requirement already satisfied: PyYAML in /usr/lib/python3/dist-packages (from ansible-core~=2.12.3->ansible) (5.3.1)
Requirement already satisfied: cryptography in /usr/lib/python3/dist-packages (from ansible-core~=2.12.3->ansible) (2.8)
Collecting jinja2
  Downloading Jinja2-3.0.3-py3-none-any.whl (133 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 133.6/133.6 KB 30.7 MB/s eta 0:00:00
Collecting packaging
  Downloading packaging-21.3-py3-none-any.whl (40 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 40.8/40.8 KB 12.3 MB/s eta 0:00:00
Collecting resolvelib<0.6.0,>=0.5.3
  Downloading resolvelib-0.5.4-py2.py3-none-any.whl (12 kB)
Collecting MarkupSafe>=2.0
  Downloading MarkupSafe-2.1.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (25 kB)
Collecting pyparsing!=3.0.5,>=2.0.2
  Downloading pyparsing-3.0.7-py3-none-any.whl (98 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.0/98.0 KB 25.1 MB/s eta 0:00:00
Building wheels for collected packages: ansible, ansible-core
  Building wheel for ansible (setup.py) ... done
  Created wheel for ansible: filename=ansible-5.5.0-py3-none-any.whl size=67481773 sha256=b16ba88b76282f47472c1408c46f13bd6669b949e077f1412041b9834facec48
  Stored in directory: /root/.cache/pip/wheels/d4/ce/b7/b8fbd32721f33a40450cc08c0bf0ba87687e584fda3c4ec8b9
  Building wheel for ansible-core (setup.py) ... done
  Created wheel for ansible-core: filename=ansible_core-2.12.3-py3-none-any.whl size=2076487 sha256=6c6402dcf6291872cab4cd7a40f4da23670b36e2f1fed866d997271192c37bfa
  Stored in directory: /root/.cache/pip/wheels/25/2d/a5/9ca95ba857e85692792dd14a19a81fb53f3f79cd4e49e457c1
Successfully built ansible ansible-core
Installing collected packages: resolvelib, pyparsing, MarkupSafe, packaging, jinja2, ansible-core, ansible
  Attempting uninstall: MarkupSafe
    Found existing installation: MarkupSafe 1.1.0
    Uninstalling MarkupSafe-1.1.0:
      Successfully uninstalled MarkupSafe-1.1.0
Successfully installed MarkupSafe-2.1.1 ansible-5.5.0 ansible-core-2.12.3 jinja2-3.0.3 packaging-21.3 pyparsing-3.0.7 resolvelib-0.5.4
WARNING: Running pip as the 'root' user can result in broken permissions and conflicting behaviour with the system package manager. It is recommended to use a virtual environment instead: https://pip.pypa.io/warnings/venv
root@ansible:~#

Once ansible is installed successfully check the version it is core 2.12.3, and run basic ping module command to test you are getting success result to localhost.

ansible --version plugin modules ansible core collection location python jinja libyaml ping module pong ping success localhost implicit gcc yaml yml file format.png

root@ansible:~# ansible --version
ansible [core 2.12.3]
  config file = None
  configured module search path = ['/root/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /usr/local/lib/python3.8/dist-packages/ansible
  ansible collection location = /root/.ansible/collections:/usr/share/ansible/collections
  executable location = /usr/local/bin/ansible
  python version = 3.8.10 (default, Nov 26 2021, 20:14:08) [GCC 9.3.0]
  jinja version = 3.0.3
  libyaml = True
root@ansible:~#
root@ansible:~# ansible localhost -m ping
[WARNING]: No inventory was parsed, only implicit localhost is available
localhost | SUCCESS => {
    "changed": false,
    "ping": "pong"
}
root@ansible:~#

Useful Article
Getting started Ansible AWX tower for IT automation run first playbook
Ansible for VMwary Using vmware_vm_inventory dynamic inventory plugin
Ansible selectattr The error was TemplateRuntimeError no test named 'equalto'
ansible create an array with set_fact
Ansible get information from esxi advanced settings nested dictionary with unique keynames
Install Ansible AWX Tower on Ubuntu Linux
Ansible AWX installation error Cannot have both the docker-py and docker python modules
Ansible AWX installation error docker-compose run --rm --service-ports task awx-manage migrate --no-input
docker: Got permission denied while trying to connect to the Docker daemon socket
Ansible AWX Tower create Manual SCM (Source Control Credential Type) project
Reset Ansible AWX Tower admin password
Install Ansible AWX on Microsoft Windows OS
Step by Step Install Ansible on Ubuntu OS
Install Ansible AWX Tower on Ubuntu Linux OS
Ansible AWX Tower Github inventory integration | Github inventory source

Go Back

Comment

Blog Search

Page Views

11383379

Follow me on Blogarama