DevOps Bootcamp · Lesson

Your ansible.cfg: Sensible Defaults

Configure the project-level settings file.

Lesson 3 of 413 steps

Your ansible.cfg: Sensible Defaults is a free DevOps Bootcamp lesson on CoddyKit. This is lesson 3 of 4. Any 3 lessons of this learning path are free to read in full — after that, CoddyKit PRO unlocks every lesson, plus hands-on practice with a built-in code editor and a 24/7 AI tutor. It is part of the DevOps Bootcamp learning path, and your progress syncs across the web and the CoddyKit app. The DevOps Bootcamp course includes 4 lessons in total.

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. 🎉

Free to start

Learn DevOps Bootcamp with an AI tutor — free

Write and run real code in your browser, get instant help from a 24/7 AI tutor, and pick up where you left off on the web or in the app.

Courses
142
Lessons
568

Frequently Asked Questions

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

Yes — any 3 lessons of the DevOps Bootcamp learning path, including “Your ansible.cfg: Sensible Defaults”, are free to read in full here on the web. After that, CoddyKit PRO unlocks every lesson, plus interactive practice with a built-in code editor and a 24/7 AI tutor. The DevOps Bootcamp course includes 4 lessons in total.

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

Configure the project-level settings file. You practise DevOps Bootcamp 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 DevOps Bootcamp?

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

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 DevOps Bootcamp lesson?

Yes. Every DevOps Bootcamp 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 DevOps Bootcamp