LOGBOOK

HELP

Quiz Entry - updated: 2026.10.30

How is an ansible.cfg file structured, and which two sections matter most for basic operation?

It is an INI-style file: section titles in square brackets, settings as key = value pairs. The two key sections are [defaults] for general behaviour and [privilege_escalation] for how Ansible becomes root on managed hosts.

[defaults]
inventory = ./inventory
remote_user = user
ask_pass = false

[privilege_escalation]
become = true
become_method = sudo
become_user = root
become_ask_pass = false
  • [defaults] holds the general settings: where the inventory is, which user to connect as, whether to ask for an SSH password.
  • [privilege_escalation] controls what happens after login: whether to switch user, how, to whom, and whether to ask for that password.

Place one such file in every Ansible project directory, so the project carries its own settings. Comments start with # at the beginning of a line; in ansible.cfg a ; also works and comments out everything to its right on that line.

Go deeper:

From Quiz: ITIA / Ansible Inventory, Configuration and Playbooks | Updated: Oct 30, 2026