SRE Automation Tools & Infrastructure as Code 2 — Questions and Answers
Question 1: Which Terraform command shows a preview of changes without applying them?
- terraform apply
- terraform plan (Correct answer)
- terraform validate
- terraform refresh
Correct answer: terraform plan
`terraform plan` generates an execution plan showing what actions Terraform will take without making any actual changes.
Question 2: In Ansible, what is the purpose of an 'inventory' file?
- Stores encrypted secrets
- Lists the managed hosts and groups (Correct answer)
- Defines task execution order
- Records playbook run history
Correct answer: Lists the managed hosts and groups
The inventory file defines the hosts and host groups that Ansible will manage and run playbooks against.
Question 3: What does 'idempotency' mean in the context of infrastructure automation?
- Automation runs faster on each execution
- Running the same operation multiple times produces the same result (Correct answer)
- Infrastructure scales automatically under load
- Changes are rolled back if an error occurs
Correct answer: Running the same operation multiple times produces the same result
Idempotency means that applying the same configuration multiple times has no additional effect beyond the first application.
Question 4: Which tool is primarily used for immutable infrastructure image creation?
- Terraform
- Ansible
- Packer (Correct answer)
- Chef
Correct answer: Packer
Packer is a HashiCorp tool that automates the creation of identical machine images for multiple platforms from a single configuration.
Question 5: In a GitOps workflow, what serves as the single source of truth for infrastructure state?
- The running production environment
- A Git repository (Correct answer)
- The CI/CD pipeline logs
- A configuration management database
Correct answer: A Git repository
GitOps uses a Git repository as the authoritative source of truth, with automated processes reconciling actual infrastructure state to match it.
Question 6: What is a Terraform 'state file' used for?
- Storing API credentials securely
- Tracking the current state of managed infrastructure (Correct answer)
- Defining provider plugins to download
- Listing available Terraform modules
Correct answer: Tracking the current state of managed infrastructure
The Terraform state file maps configuration to real-world resources, allowing Terraform to determine what changes need to be made.
Question 7: Which Ansible feature allows sensitive data like passwords to be stored encrypted in version control?
- Ansible Facts
- Ansible Vault (Correct answer)
- Ansible Galaxy
- Ansible Collections
Correct answer: Ansible Vault
Ansible Vault encrypts sensitive data such as passwords and keys so they can be safely stored alongside playbooks in version control.
Which Terraform command shows a preview of changes without applying them?