User Tools

Site Tools


ansible

This is an old revision of the document!


Ansible

Installing

RHEL has ansible-core, podman, and ansible-navigator in the OS repositories.

Ubuntu needs a PPA:

sudo add-apt-repository --yes --update ppa:ansible/ansible
sudo apt install ansible -y

It can also be installed with Python

sudo apt install python3-pip -y
pip3 install ansible

Inventory and Config

The config is read from: ANSIBLE_CONFIG, ./ansible.cfg, ~/ansible.cfg, /etc/ansible/ansible.cfg

[defaults]
inventory = ./ansible_hosts  # relative to path of ansible.cfg
nocows = True
interpreter_python = /usr/bin/python3
gathering = False
forks = 2
strategy = free
host_key_checking = False

[ssh_connection]
pipelining = True
ssh_args = -o ControlMaster=auto -o ControlPersist=60s

The default inventory path is /etc/ansible/hosts

genpurpose1host.localdomain  # ungrouped

[web]
webserver1 ansible_connection=ssh ansible_host=webserver1.localdomain ansible_port=2022 ansible_user=webadmin
localhost ansible_connection=local

[worker]
worker1

[app:children]
web
worker

[all:vars]
ansible_connection=ssh
ansible_ssh_user=myuser
ansible_ssh_private_key_file=my_ssh_key
#ansible_ssh_pass=mypass
#ansible_become_pass=mypass
ansible.1772361574.txt.gz · Last modified: by reddy

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki