CDM Infrastructure Automation & Configuration Management 2 — Questions and Answers
Question 1: In Terraform, what is the purpose of the `terraform state mv` command?
- Delete a resource from the state file
- Move a resource to a different state file or rename it within state (Correct answer)
- Import an existing resource into Terraform management
- Refresh the state file to match real infrastructure
Correct answer: Move a resource to a different state file or rename it within state
`terraform state mv` relocates a resource record within or between state files without destroying and recreating the real infrastructure.
Question 2: Which Ansible module is best suited for ensuring a specific line exists in a configuration file without duplicating it?
- copy
- template
- lineinfile (Correct answer)
- blockinfile
Correct answer: lineinfile
The `lineinfile` module manages individual lines in files, adding or updating them idempotently based on a regexp match.
Question 3: What does the concept of 'immutable infrastructure' primarily advocate?
- Encrypting all infrastructure configuration files at rest
- Replacing servers with new images rather than updating them in place (Correct answer)
- Preventing any changes to production systems by non-admins
- Using version-locked dependencies in all deployment pipelines
Correct answer: Replacing servers with new images rather than updating them in place
Immutable infrastructure replaces servers entirely with freshly built images instead of patching running instances, reducing configuration drift.
Question 4: In Chef, what is the role of a 'cookbook'?
- A report summarizing the last Chef client run on a node
- A versioned package containing recipes, attributes, and resources that define a configuration policy (Correct answer)
- A list of nodes that belong to a specific Chef environment
- The Chef server's web UI for managing node configurations
Correct answer: A versioned package containing recipes, attributes, and resources that define a configuration policy
A Chef cookbook is the fundamental unit of configuration, bundling recipes, attributes, templates, and custom resources into a versioned package.
Question 5: Which Terraform feature allows multiple configurations to share the same infrastructure state?
- Data sources
- Remote backends with workspaces (Correct answer)
- Module registries
- Provider aliases
Correct answer: Remote backends with workspaces
Remote backends such as S3 or Terraform Cloud combined with workspaces allow teams to share and isolate state across environments.
Question 6: What is 'configuration drift' in infrastructure management?
- A scheduled rotation of infrastructure credentials to improve security
- Gradual divergence between the desired state defined in code and the actual state of running systems (Correct answer)
- The migration of workloads from on-premises to cloud infrastructure
- Version skew between different Terraform provider plugins
Correct answer: Gradual divergence between the desired state defined in code and the actual state of running systems
Configuration drift occurs when manual changes or unmanaged updates cause live systems to differ from the intended state described in code.
Question 7: In Puppet, which resource type enforces that a user account exists with specific properties on a managed node?
- exec
- file
- user (Correct answer)
- package
Correct answer: user
The Puppet `user` resource type manages local user accounts, allowing you to declare their UID, groups, shell, and password state.
In Terraform, what is the purpose of the `terraform state mv` command?