Ansible - Installation - Version 2.7 on Linux

1 - About

How to install Ansible on Linux.

2 - Steps

  • using the OS package manager for Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu, we recommend
  • using Pip

2.1 - Python installation

Ansible’s “raw” module don’t even need Python installed. So technically, you can use Ansible to install a compatible version of Python using the raw module, which then allows you to use everything else.


ansible host-pattern --become -m raw -a "yum install -y python2"

2.2 - Interpreter

By default, Ansible uses the python interpreter located at /usr/bin/python to run its modules.

If it's not the case, you can set the ansible_python_interpreter inventory variable to point at your interpreter

2.3 - Azure

See Install Ansible

  • Ubuntu

## Install pre-requisite packages
sudo apt-get update && sudo apt-get install -y libssl-dev libffi-dev python-dev python-pip

## Install Ansible and Azure SDKs via pip
sudo pip install ansible[azure]

  • Centos

sudo yum check-update; sudo yum install -y gcc libffi-devel python-devel openssl-devel epel-release
sudo yum install -y python-pip python-wheel

2.4 - Test if Ansible is installed

From Ansible task …?

- name: Install ansible
  yum: pkg=ansible state=installed

3 - Verification

pip show ansible

Metadata-Version: 1.1
Name: ansible
Version: 2.7.1
Summary: Radically simple IT automation
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/lib/python2.7/dist-packages
  Development Status :: 5 - Production/Stable
  Environment :: Console
  Intended Audience :: Developers
  Intended Audience :: Information Technology
  Intended Audience :: System Administrators
  License :: OSI Approved :: GNU General Public License v3 or later (GPLv3+)
  Natural Language :: English
  Operating System :: POSIX
  Programming Language :: Python :: 2
  Programming Language :: Python :: 2.7
  Programming Language :: Python :: 3
  Programming Language :: Python :: 3.5
  Programming Language :: Python :: 3.6
  Programming Language :: Python :: 3.7
  Topic :: System :: Installation/Setup
  Topic :: System :: Systems Administration
  Topic :: Utilities

4 - Docker

5 - Support

5.1 - "module_stdout": "/bin/sh: /usr/bin/python: No such file or directory\r\n"

Verify your interpreter

Data Science
Data Analysis
Data Science
Linear Algebra Mathematics

Powered by ComboStrap