About
How to install Ansible on Linux.
Steps
- using the OS package manager for Red Hat Enterprise Linux (TM), CentOS, Fedora, Debian, or Ubuntu, we recommend
- using Pip
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.
Example:
ansible host-pattern --become -m raw -a "yum install -y python2"
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
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
Test if Ansible is installed
From Ansible task …?
- name: Install ansible
yum: pkg=ansible state=installed
Verification
pip show ansible
---
Metadata-Version: 1.1
Name: ansible
Version: 2.7.1
Summary: Radically simple IT automation
Home-page: https://ansible.com/
Author: Ansible, Inc.
Author-email: [email protected]
License: GPLv3+
Location: /usr/lib/python2.7/dist-packages
Requires:
Classifiers:
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
Docker
- https://github.com/ansible/ansible-docker-base - deprecated
Support
“module_stdout”: “/bin/sh: /usr/bin/python: No such file or directory\r\n”
Verify your interpreter