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 121–135 of 188 questions

121.Two engineers run terraform apply at the same time. What happens?MidTerraform

With a locking backend, the second run fails with a lock error until the first finishes; that is what the lock is for. Without locking, both can write state at once and corrupt it or create duplicates. Use a backend with locking and run applies only from CI so there is one path to change.

122.What happens if you delete a resource block from your code?MidTerraform

The next apply destroys the real resource. If you want to keep it but stop managing it with Terraform, use a removed block with destroy = false (or terraform state rm on older versions).

123.How do you roll back a Terraform change?MidTerraform

There is no rollback button. Revert the commit and apply again so the code puts things back. If the state file itself is broken, restore an earlier version from the backend's versioning (for example S3 versioning).

124.Why does my plan show a change every time even though nothing changed?MidTerraform

Something differs on every run: a value like timestamp() in tags, another tool editing the same field, or the provider formatting a value differently (common with JSON policies). Fix the code, use jsonencode, or add ignore_changes for fields another system owns.

125.terraform apply says the resource already exists. Why?MidTerraform

The resource exists in the cloud but not in state, because it was created by hand or the state was lost. Import it with an import block instead of creating it again.

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

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

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

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

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

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

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

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

134.What is the difference between a security group and a NACL?MidAWS

A security group belongs to an instance, is stateful and only has allow rules. A NACL belongs to a subnet, is stateless, and has numbered allow and deny rules. Most control is done with security groups.

135.How does a private subnet reach the internet?MidAWS

Through a NAT gateway in a public subnet. The private route table sends 0.0.0.0/0 to the NAT gateway, which sends it on through the internet gateway. Nothing from outside can start a connection in.