SRE Automation Tools & Infrastructure as Code 4 — Questions and Answers
Question 1: What does 'immutable infrastructure' mean in SRE practice?
- Infrastructure that cannot be modified by any team member
- Servers are replaced rather than updated when changes are needed (Correct answer)
- Infrastructure configuration that is read-only in Git
- Databases that prevent schema changes after deployment
Correct answer: Servers are replaced rather than updated when changes are needed
Immutable infrastructure means that once deployed, servers are never modified in place; instead they are replaced with new instances containing the updates.
Question 2: Which Terraform resource type allows you to run arbitrary scripts during provisioning?
- terraform_data
- null_resource with provisioner (Correct answer)
- local_file
- terraform_remote_state
Correct answer: null_resource with provisioner
A `null_resource` with a `provisioner` block (local-exec or remote-exec) allows running arbitrary scripts as part of Terraform provisioning.
Question 3: In Ansible, what is the difference between a 'task' and a 'role'?
- Tasks are for Linux hosts; roles are for Windows hosts
- A role is a reusable collection of tasks, variables, and handlers organized in a standard structure (Correct answer)
- Tasks run in parallel; roles run sequentially
- Roles require root access; tasks do not
Correct answer: A role is a reusable collection of tasks, variables, and handlers organized in a standard structure
An Ansible role packages related tasks, handlers, variables, and files into a reusable, shareable unit with a standardized directory structure.
Question 4: What problem does remote Terraform state storage (e.g., S3 + DynamoDB) solve?
- It reduces the time required for terraform plan
- It enables team collaboration and prevents concurrent state modifications (Correct answer)
- It automatically encrypts all managed resources
- It provides rollback capability for failed deployments
Correct answer: It enables team collaboration and prevents concurrent state modifications
Remote state storage enables multiple team members to share state and uses locking (e.g., DynamoDB) to prevent simultaneous conflicting changes.
Question 5: Which testing approach validates that Terraform modules produce the expected infrastructure?
- Unit testing with terraform fmt
- Integration testing with tools like Terratest (Correct answer)
- Load testing with terraform apply -parallelism
- Smoke testing with terraform init
Correct answer: Integration testing with tools like Terratest
Terratest is a Go library that enables integration testing of Terraform modules by actually deploying infrastructure and validating its behavior.
Question 6: What is the purpose of Ansible 'handlers'?
- They define the order in which playbooks run
- They are tasks triggered only when notified by other tasks (Correct answer)
- They manage connection settings for remote hosts
- They store variables used across multiple playbooks
Correct answer: They are tasks triggered only when notified by other tasks
Handlers are special tasks that only run when notified by other tasks, typically used for actions like restarting a service after a configuration change.
Question 7: In the context of SRE and IaC, what is a 'golden image'?
- A Terraform configuration file with no errors
- A pre-built, pre-configured machine image used as a base for new instances (Correct answer)
- An Ansible playbook that passed all CI checks
- A Kubernetes pod running with optimal resource limits
Correct answer: A pre-built, pre-configured machine image used as a base for new instances
A golden image is a vetted, pre-configured machine image that serves as a standardized starting point for deploying new servers, reducing configuration time.
What does 'immutable infrastructure' mean in SRE practice?