Installation et inventaire 15 min de lecture

Installer Ansible

Installation sur Ubuntu/Debian

# Methode recommandee : via apt
sudo apt update
sudo apt install -y ansible

# OU via pip (derniere version)
sudo apt install -y python3-pip
pip3 install ansible

# Verifier l'installation
ansible --version

Installation sur CentOS/RHEL

# Activer le depot EPEL
sudo yum install -y epel-release
sudo yum install -y ansible

# OU via pip
pip3 install ansible

Fichier de configuration ansible.cfg

Ansible cherche sa configuration dans cet ordre :

  1. ANSIBLE_CONFIG (variable d'environnement)
  2. ./ansible.cfg (repertoire courant)
  3. ~/.ansible.cfg (repertoire home)
  4. /etc/ansible/ansible.cfg (global)
# ansible.cfg minimal
[defaults]
inventory = ./inventory
remote_user = deploy
host_key_checking = False

[privilege_escalation]
become = True
become_method = sudo
become_user = root
Bonne pratique : Placez toujours un fichier ansible.cfg a la racine de votre projet Ansible.