Definitions

Here’s a complete list of Ansible concepts, components, and objects with definitions. This will cover everything an interviewer might ask.


1. Core Concepts in Ansible

1.1. Ansible

An open-source configuration management, automation, and orchestration tool used to provision and manage infrastructure declaratively.

1.2. Agentless

Ansible does not require agents on managed nodes. It uses SSH for Linux and WinRM for Windows.

1.3. Idempotency

Ensures that running the same Ansible playbook multiple times produces the same result without unintended changes.

1.4. Push vs Pull Mode

  • Push Mode (default): The Ansible control node pushes configurations to target nodes.

  • Pull Mode: Managed nodes fetch configurations from a central repository (using ansible-pull).


2. Key Components & Objects in Ansible

2.1. Inventory

A file that lists managed nodes (hosts) along with their IPs, groupings, and variables.

  • Default: /etc/ansible/hosts

  • Formats: INI, YAML, or Dynamic Inventory (AWS, Azure, GCP).

πŸ‘‰ Example (INI format)


2.2. Playbook

A YAML file containing tasks that define automation steps.

  • It contains plays that run sequentially on managed nodes.

πŸ‘‰ Example


2.3. Tasks

Individual units of work inside a playbook. They execute modules to perform specific actions (e.g., install a package, restart a service).

πŸ‘‰ Example


2.4. Modules

Reusable Ansible plugins that execute specific actions on nodes.

πŸ“Œ Types of Modules:

  • System Modules: service, apt, yum, firewalld

  • File Modules: copy, file, fetch, template

  • Cloud Modules: ec2_instance, gcp_compute_instance

  • User Modules: user, group, hostname

πŸ‘‰ Example (Using copy module)


2.5. Roles

A structured way to organize Ansible playbooks into reusable components. Each role contains tasks, handlers, templates, and variables.

πŸ“Œ Role Directory Structure

πŸ‘‰ Run a Role in Playbook


2.6. Handlers

Similar to tasks but only run when notified by another task. Commonly used for restarting services after configuration changes.

πŸ‘‰ Example


2.7. Variables

Allow parameterization in playbooks.

πŸ“Œ Types of Variables:

  • Defined in Playbooks

  • Defined in Inventory

  • Facts (Gathered from Nodes)

  • External Variables (via vars_files)

πŸ‘‰ Example


2.8. Templates (Jinja2)

Dynamic configuration files using Jinja2 templating.

πŸ‘‰ Example (nginx.conf.j2)

πŸ‘‰ Apply Template in Playbook


2.9. Facts

Automatically collected system information about managed nodes.

πŸ‘‰ Check facts manually

πŸ‘‰ Use a fact in a Playbook


2.10. Conditionals

Execute tasks based on conditions.

πŸ‘‰ Example


2.11. Loops

Run a task multiple times.

πŸ‘‰ Example (Looping through a list)


2.12. Tags

Run only specific parts of a playbook.

πŸ‘‰ Tagging a Task

πŸ‘‰ Run Playbook with a Specific Tag


2.13. Ansible Vault

Encrypts sensitive information (passwords, keys) in playbooks.

πŸ‘‰ Encrypt a file

πŸ‘‰ Use Vault in a Playbook


2.14. Ansible Galaxy

A community repository for Ansible roles.

πŸ‘‰ Install a Role from Galaxy


2.15. Ansible Pull

Used for agent-based Ansible deployments.

πŸ‘‰ Example


Conclusion

This covers all major Ansible concepts that interviewers typically ask.

Pro Tip πŸ’‘

πŸ’¬ Before the interview:

  • Revise key modules (apt, yum, copy, template, service).

  • Practice YAML syntax & playbooks.

  • Prepare real-world use cases from your experience.

Let me know if you need mock interview questions or playbook scenarios. πŸš€

Last updated