Skip to content
$ lynuxpro

INTERVIEW PREP

Interview questions

570 questions from real DevOps, SRE, platform engineering and MLOps interviews, with the answer an interviewer wants to hear. Try answering out loud first, then open the model answer.

Showing 151–165 of 314 questions

151.What is a module?BeginnerAnsible

A small, ready-made tool for one job, such as installing a package or copying a file. Tasks call modules.

152.Why prefer modules over command or shell?MidAnsible

Modules check the current state and only change what is needed, and they report changed correctly. command and shell run blindly, so you must add creates or changed_when to make them safe.

153.How does variable precedence work in practice?MidAnsible

More specific or deliberate places win. Role defaults are lowest, then group_vars, host_vars and play vars, and extra vars passed with -e are strongest.

154.What are facts?MidAnsible

Data Ansible collects about each server at the start of a play, such as the OS name, IP addresses and memory. You can use them in conditions and templates.

155.What is a handler and when does it run?MidAnsible

A task that runs only when notified by a task that reported changed. It runs once at the end of the play, for example to restart a service after a config change.

156.What is a role?MidAnsible

A folder with a standard layout (tasks, handlers, templates, defaults and more) that packages one job so it can be reused and shared.

157.How do you manage secrets?MidAnsible

With Ansible Vault: encrypt files or single values, pass the password at run time, keep the password out of Git, and use no_log on tasks that handle secrets.

158.Why use a dynamic inventory?MidAnsible

In the cloud, servers come and go. A dynamic inventory plugin asks the provider for the current servers on each run and can build groups from tags.

159.How do you do a rolling update with no downtime?MidAnsible

Use serial to update in batches, often one server first and then larger groups, with max_fail_percentage to stop if too many fail, plus health checks and a load balancer.

160.How do block, rescue and always work?SeniorAnsible

block holds the normal tasks. If one fails, rescue runs, for example to roll back. always runs in either case, like finally.

161.How would you speed up a slow playbook?SeniorAnsible

Raise forks, turn on SSH pipelining and connection reuse, cache or skip facts, use the free strategy where safe, run long jobs async, and measure with profile_tasks.

162.How do you test a role?SeniorAnsible

With Molecule: start a disposable container, converge the role, run it again to check idempotence, run verify checks, and destroy the container. Run it in CI on every change.

163.How do you run Ansible safely in CI/CD?SeniorAnsible

Lint and dry-run (--check --diff) on merge requests, deploy from the main branch with a manual gate, keep SSH keys and the vault password in protected variables, and pin versions.

164.What is a collection, and why pin versions?SeniorAnsible

A package of modules, roles and plugins named namespace.collection. Pinning versions in requirements.yml keeps runs the same and stops upstream updates from changing behaviour.

165.When would you write a custom module?SeniorAnsible

Only when no existing module or collection can do the job, such as for an internal API. It must be idempotent, support check mode, return correct JSON and be documented.