LearnThatStack Ace your next interview
Practice · Questions

All questions

Showing of 34
Beginner 8
01

Explain the difference between Ansible Playbooks, Plays, and Tasks.

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

A playbook is the YAML file you run, and it holds one or more plays in order. A play maps a group of hosts to the tasks that run on them, and sets how those tasks run. A task is one unit of work that calls a single Ansible module, such as yum or service.

A play's hosts line picks machines from the inventory, and play keywords such as become or vars apply to every task in it. A playbook with two plays can set up the web servers first and the databases second.

By default, Ansible runs each task on every host in the play before it starts the next task.

# Playbook
- name: Web server setup          # Play 1
  hosts: webservers
  tasks:
    - name: Install Apache        # Task 1
      yum:
        name: httpd
        state: present
    - name: Start Apache          # Task 2
      service:
        name: httpd
        state: started
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

02

What is an Ansible Inventory and what are the different types?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An inventory lists the hosts Ansible manages and sorts them into groups that playbooks target by name, such as webservers. There are two types.

A static inventory is a file you write by hand, in INI or YAML. Groups can hold other groups, as production does here.

[webservers]
web1.example.com
web2.example.com

[databases]
db1.example.com ansible_host=192.168.1.100
[production:children]
webservers
databases

Here is the same webservers group in YAML.

all:
  children:
    webservers:
      hosts:
        web1.example.com:
        web2.example.com:

A dynamic inventory builds the host list at run time from a source such as AWS, Azure or GCP. It suits the cloud, where hosts come and go. Ansible recommends inventory plugins for this over the older inventory scripts. A script can use any language that prints the hosts and groups as JSON.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

03

What are Ansible Facts and how do you use them?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Ansible facts are details Ansible collects about each managed host, such as its OS, hardware and network configuration. By default, the setup module gathers them at the start of every play. You read them from ansible_facts, or as top-level variables with an ansible_ prefix. Installed packages are not part of the default facts. The package_facts module collects those when you need them.

Facts let one playbook adapt to each host.

- name: Display OS information
  debug:
    msg: "This host runs {{ ansible_distribution }} {{ ansible_distribution_version }}"
- name: Conditional based on facts
  yum:
    name: httpd
    state: present
  when: ansible_os_family == "RedHat"

You can also set facts of your own. set_fact sets them for the rest of the run.

- name: Set custom fact
  set_fact:
    custom_variable: "custom_value"

When a play never reads facts, set gather_facts: false on the play. It skips the gathering step, which speeds up runs on large inventories.

- name: Disable fact gathering
  hosts: webservers
  gather_facts: false
Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

04

What does it mean that Ansible is agentless, and how does it differ from Puppet?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Agentless means Ansible installs nothing permanent on the managed nodes it controls. The control node connects to each managed node over SSH and pushes small programs called modules. It runs them there, then removes them when they finish. Windows nodes usually connect over WinRM instead.

A Linux or Unix managed node needs only Python and a user account Ansible can log in with over SSH. There is no daemon to install, upgrade or secure on every node.

Puppet works the other way. Each managed node runs a Puppet agent that pulls a compiled catalog from a primary server and applies it. That pull model corrects drift on every agent run, but every node needs the agent installed and maintained.

Ansible pushes changes when you run a playbook, so changes happen when you choose. ansible-pull inverts this, so each node fetches playbooks from Git and runs them itself, usually from cron.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

05

What is the difference between ad-hoc commands and playbooks in Ansible?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

An ad-hoc command is a one-off, while a playbook is reusable. The ad-hoc command runs one module against a set of hosts, straight from the command line with the ansible tool. The playbook is a YAML file of ordered plays and tasks. You run it with ansible-playbook and keep it in version control.

# Check that every web server responds
ansible webservers -m ansible.builtin.ping
# Restart a service on all of them, with sudo
ansible webservers -m ansible.builtin.service -a "name=httpd state=restarted" --become
# Reboot a group of servers
ansible atlanta -a "/sbin/reboot"

-m picks the module and -a passes its arguments. Without -m, Ansible runs the command module.

Use ad-hoc commands for quick, one-off jobs, such as checking connectivity or rebooting a group of servers. They are fast to type but not reusable.

Use a playbook for anything you will repeat or review. It chains many tasks with variables, handlers and roles, and it runs the same way every time. Both call the same modules, so an ad-hoc command that works turns into a playbook task almost word for word.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

06

What does ansible.cfg control, and where does Ansible look for it?

Beginner ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

ansible.cfg sets Ansible's defaults for a project, such as the inventory path, the remote user and how many hosts to run at once. Ansible reads only the first config file it finds, in this order:

  1. The file named in the ANSIBLE_CONFIG environment variable
  2. ansible.cfg in the current directory
  3. ~/.ansible.cfg in your home directory
  4. /etc/ansible/ansible.cfg

The others are ignored, not merged. So keep an ansible.cfg in each project's root and run Ansible from there, and every teammate gets the same settings.

[defaults]
inventory = ./inventory
remote_user = deploy
forks = 20

[privilege_escalation]
become = true

Two catches. Ansible skips an ansible.cfg in a world-writable current directory, because another user could plant one there. And config settings have the lowest precedence: an ANSIBLE_ environment variable overrides the file, and command-line options, playbook keywords and variables override both.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

07

How do you implement conditionals in Ansible?

Part of Pro
08

How do you implement loops in Ansible?

Part of Pro
Intermediate 16
09

How do you handle sensitive data like passwords in Ansible?

Intermediate ·

Answer it yourself first - out loud, or typed below.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Last attempt -

Your answer

Re-explain

Encrypt secrets with Ansible Vault, keep them out of task output with no_log, and keep the vault password out of the repository. Vault encrypts a whole file or a single variable, so the encrypted content can sit in source control beside the playbooks. When a playbook runs, you supply the vault password and Ansible decrypts what it needs.

# Encrypt a file
ansible-vault encrypt secrets.yml

# Decrypt a file
ansible-vault decrypt secrets.yml

# Edit encrypted file
ansible-vault edit secrets.yml

# Run playbook with vault password
ansible-playbook site.yml --ask-vault-pass

# Use vault password file
ansible-playbook site.yml --vault-password-file .vault_pass

Encrypting only the sensitive values keeps the rest of a vars file readable in code review.

# vars.yml
username: john
password: !vault |
  $ANSIBLE_VAULT;1.1;AES256
  66386439653762356265343432393730...

Four habits keep it safe:

  • Keep the vault password in a file only its owner can read, set with chmod 600, and never commit it.
  • Use a separate vault file for each environment, each with its own password.
  • Encrypt only the sensitive variables, not entire playbooks.
  • Add no_log: true to tasks that handle secrets. Vault protects data only at rest, so a decrypted value would otherwise show up in output and logs.

When many teams share secrets or rotate them often, fetch them at run time from an external manager such as HashiCorp Vault instead.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

Related concept

Tailored explanation · switch back to · ·
What should the new diagram focus on?
How well did you know this?
AI:

10

Explain Ansible Roles and their directory structure.

Part of Pro
11

What are Ansible Variables and what is the order of precedence?

Part of Pro
12

Explain Ansible Handlers and when to use them.

Part of Pro
13

Explain Ansible Galaxy and how to create custom roles.

Part of Pro
14

How do you implement error handling in Ansible?

Part of Pro
15

What are Ansible Collections and how do they differ from roles?

Part of Pro
16

How do you manage different environments (dev, staging, prod) in Ansible?

Part of Pro
17

How do you test Ansible playbooks and roles?

Part of Pro
18

Explain Ansible's idempotency and how to ensure it in custom tasks.

Part of Pro
19

How do you handle Ansible playbook debugging and troubleshooting?

Part of Pro
20

How do you monitor and log Ansible operations?

Part of Pro
21

What is the difference between import_tasks and include_tasks?

Part of Pro
22

How do you delegate a task to another host in Ansible?

Part of Pro
23

How do you use Jinja2 templates in Ansible?

Part of Pro
24

What do AWX and Ansible Automation Platform add on top of the Ansible CLI?

Part of Pro
Expert 10
25

How do you optimize Ansible performance for large infrastructures?

Part of Pro
26

Explain Ansible Vault and how to manage multiple vault passwords.

Part of Pro
27

How do you create and use custom Ansible modules?

Part of Pro
28

What are Ansible plugins and how do you create them?

Part of Pro
29

How do you implement rolling deployments with Ansible?

Part of Pro
30

How do you manage secrets and integrate with external secret management systems?

Part of Pro
31

What are Ansible callbacks and how do you create custom ones?

Part of Pro
32

How do you implement infrastructure as code with Ansible for cloud platforms?

Part of Pro
33

How do you implement Ansible in CI/CD pipelines?

Part of Pro
34

What are some Ansible security best practices?

Part of Pro

No matches

Try a different filter or search term.

Know someone prepping for Ansible? Send them this set.
Pro · $10/mo

27 of 34 Ansible answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime

Change topic

Pick a different technology or stack. Your current topic stays put until you choose a new one.

Technologies
No technologies match “”.
Cross-cutting topics
No topics match “”.
By role
Stacks & frameworks

MEAN

MongoDB, Express, Angular, Node.js

MERN

MongoDB, Express, React, Node.js

LAMP

Linux, Apache, MySQL, PHP

Django

Python Full-Stack Development

Ruby on Rails

Convention over Configuration

Serverless on AWS

Serverless Architecture on AWS

Flutter Mobile

Flutter Cross-Platform Mobile Development

Spring Boot

Enterprise Java Development

.NET

Microsoft Ecosystem

Vue

Vue.js, Vite, TypeScript, Tailwind, Node.js

Go Backend

Golang, gRPC, PostgreSQL, Redis, RabbitMQ

FastAPI

Python, FastAPI, SQLAlchemy, PostgreSQL

React Native

React, TypeScript, Redux, Firebase

iOS Native

Swift, SwiftUI, UIKit, Firebase

Android Native

Java, Jetpack Compose, Firebase

DevOps / Platform

Docker, Kubernetes, Terraform, CI/CD

AI Engineer

LLMs, RAG, Agents, Evals

AI-Powered Developer

Claude Code, Copilot, Agentic Workflows

Core SWE Interview Prep

Data structures, algorithms, OS, concurrency, networking, git