Interview Infrastructure as Code (Terraform, Ansible)

What is Ansible, and how is it agentless?

Infrastructure as Code (Terraform, Ansible) · Intermediate level

Answer

Ansible is an automation and configuration management tool that runs tasks from a control node against managed hosts. It is agentless because managed Linux hosts usually only need SSH and Python, while Windows hosts use WinRM; there is no long-running Ansible agent to install.

Technical explanation

Agentless reduces bootstrap requirements and makes Ansible attractive for heterogeneous fleets.

The control node pushes modules to targets for execution and collects structured results.

Managed hosts still need network reachability, credentials, privilege escalation, and suitable interpreters.

Prefer idempotent modules over shell so repeated runs are safe and change reporting is meaningful.

Separate reusable role logic from inventory-specific variables so the same automation works across environments.

Run lint, syntax checks, check mode where useful, and staged rollouts before production-wide changes.

Hands-on example

1. Create a minimal Ansible control workflow for: What is Ansible, and how is it agentless?

2. Inventory example:

[web]

web1 ansible_host=10.0.1.10 ansible_user=ec2-user

web2 ansible_host=10.0.1.11 ansible_user=ec2-user

[web:vars]

ansible_become=true

3. Playbook example:

---

- name: Configure web hosts

hosts: web

become: true

tasks:

- name: Ensure nginx is installed

ansible.builtin.package:

name: nginx

state: present

- name: Ensure nginx is running

ansible.builtin.service:

name: nginx

state: started

enabled: true

4. Run ansible -m ping web first, then ansible-playbook site.yml --check --diff, then the real run.

Preparing for an interview?

Check how well your resume matches the role with our free resume checker— match score, ATS check, and the skills you're missing.

More Infrastructure as Code (Terraform, Ansible) interview questions

← All Infrastructure as Code (Terraform, Ansible) questions