0Pricing
Ansible Academy · Lesson

Your ansible.cfg: Sensible Defaults

Configure the project-level settings file.

Your ansible.cfg: Sensible Defaults is a free Ansible Academy lesson on CoddyKit — lesson 3 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the Ansible Academy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

The Config File

Ansible reads settings from ansible.cfg. It controls defaults like which inventory to use and how to connect, so you type less.

Project-Level Wins

Drop an ansible.cfg in your project folder. A local file beats the global one, keeping each project's settings self-contained.

The Search Order

Ansible checks ANSIBLE_CONFIG, then the current dir, then your home, then /etc. The first match wins, so the project file usually rules.

It Uses INI Sections

The file is plain INI: settings sit under headers like [defaults]. Most everyday options live in that defaults section.

[defaults]
inventory = ./inventory.ini

Set a Default Inventory

Point inventory at your hosts file so you can drop the -i flag on every command. One line saves endless typing.

[defaults]
inventory = ./hosts

Pick the remote_user

Set remote_user so Ansible always logs in as the right account, instead of guessing your current local username.

[defaults]
remote_user = deploy

Tame Host Key Checks

On fresh lab hosts, host_key_checking = False skips the unknown-host prompt. Keep it on in production for security.

[defaults]
host_key_checking = False

Control Output

Make runs readable with the stdout_callback = yaml plugin. It formats results as tidy YAML instead of a dense one-liner.

[defaults]
stdout_callback = yaml

Privilege Section

The [privilege_escalation] section sets how Ansible becomes root. Turn become on here to avoid repeating it everywhere.

[privilege_escalation]
become = True

Confirm What Loaded

Not sure which config is active? ansible --version prints the exact ansible.cfg path Ansible chose at startup.

ansible --version

Sensible Defaults

A small ansible.cfg removes repetitive flags and makes your project portable across teammates. Set it once, benefit forever. ⚙️

Quick Check

Check your config knowledge.

Recap

A project ansible.cfg sets your inventory, remote_user, and output, so commands stay short. The closest file wins the search order. 🎉

Frequently asked questions

Is the “Your ansible.cfg: Sensible Defaults” lesson free?

Yes — the full text of “Your ansible.cfg: Sensible Defaults” is free to read here on the web, and the Ansible Academy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the Ansible Academy course, upgrade to CoddyKit PRO.

What will I learn in “Your ansible.cfg: Sensible Defaults”?

Configure the project-level settings file. You practise Ansible Academy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start Ansible Academy?

No prior experience is required. Ansible Academy on CoddyKit is structured for beginners through advanced learners; this is — lesson 3 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Your ansible.cfg: Sensible Defaults” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this Ansible Academy lesson?

Yes. Every Ansible Academy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Installing the Ansible Control Node
  2. SSH Keys & Passwordless Login
  3. Your ansible.cfg: Sensible Defaults
  4. Ping a Host with the ping Module
← Back to Ansible Academy