Ansible - Installation
Ansible is installed on the control node but does not need to be installed on the managed nodes. The managed nodes do need Python and SSH access. Most systems should have this by default.
- Control node - Just the machine that you run Ansible commands on. Could be a centralized server or just a laptop.
- Managed node - Just the hosts that you connect to and manage using Ansible.
Two different options:
- ansible - batteries included package ( recommended by me ), community package with extra stuff, similar to original ansible
- ansible-core - minimal package, includes Ansible.Builtin
NOTE
- Just to be clear, pick either ansible or ansible-core, not both. I recommend ansible because it will make things easier.
- When using pip or an OS package manager you can generally specify either of these package names to get the respective version of ansible:
- ansible
- ansible-core
Another tool:
- ansible-galaxy - client tool for Ansible Galaxy, can download roles
Prerequisites ( prob out of date by the time you read this, just get the latest )::
- Python 3.8 for control node ( 2.11 )
- Python 2.6 or 3.5 for managed nodes
- libselinux-python if you have selinux
NOTE - Might need to install sshpass before you can prompt for SSH passwords:
sudo apt install sshpass
Check what version you have after in stallation:
ansible --version
Package Manager Install ( easy way )
Install on Red Hat systems:
sudo dnf install ansible # Fedora
sudo yum install ansible # RHEL ( older versions )
On current Debian / Ubuntu systems:
sudo apt update && sudo apt install -y ansible
Ubuntu installation ( might not be needed anymore no newer versions )::
sudo apt update
sudo apt install software-properties-common
sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible
Install on Arch Linux:
pacman -S ansible
Pip Install
Install using Pip (or pip3 or pipx ):
pip install ansible
Github - Install Latest Version
Install Ansible core from github:
git clone https://github.com/ansible/ansible.git
git clone -b stable-2.17 https://github.com/ansible/ansible.git
cd ./ansible
source ./hacking/env-setup
source ./hacking/env-setup.fish
Python on Managed Nodes
Mosts hosts probably have Python installed already and it should be a new enough version unless it is very old. If you don’t have Python installed on your remote hosts for whatever reason, you won’t be able to run most ansible modules against those hosts. You can still run the raw module because that doesn’t need Python. Use that to install Python as shown here.
Use raw mode to install python:
ansible myhost --become -k -K -m raw -a "yum install -y python3"
ansible myhost --become -k -K -m raw -a "yum install -y python3"