Explore key concepts of Infrastructure as Code (IaC), focusing on automation and configuration using Terraform and Ansible. Test your foundational knowledge about templates, provisioning, state management, syntax, and more within IaC workflows.
Which main benefit does Infrastructure as Code (IaC) provide when managing IT infrastructure?
Explanation: IaC allows infrastructure to be provisioned automatically using code, making deployments repeatable and reducing errors. Increasing manual steps and hardware-only deployment contradict automation goals. Limiting scalability is not a benefit of IaC—automation actually supports increased scale.
In Terraform, which file extension is typically used for infrastructure configuration files?
Explanation: Terraform uses files with the .tf extension to define infrastructure resources. .yaml files are often used with other tools, but not Terraform. .sh is for shell scripts, while .ini is used for configuration in some legacy systems.
What is the primary purpose of an inventory file in Ansible?
Explanation: An inventory file in Ansible outlines which hosts or groups tasks are applied to. It does not store logs, compile modules, or handle billing. These distractors relate to other aspects of system administration, but not to Ansible's inventory function.
Why does Terraform maintain a 'state' file during infrastructure management?
Explanation: Terraform's state file keeps track of the resources it manages and their attributes. Temporary storage of variables is handled within code, not the state file. Debugging and module listing are separate features unrelated to state.
Which language format is primarily used to write Ansible Playbooks?
Explanation: Ansible playbooks are written in YAML format, which is both human-readable and easy for automation tools to interpret. While Ansible is implemented in Python, and JSON/XML are used in other contexts, playbooks specifically require YAML.
What does running the 'plan' command in Terraform accomplish before applying changes?
Explanation: The 'plan' command in Terraform previews upcoming changes, allowing you to review them before applying. It does not apply or delete resources directly, and is not used for disk monitoring. Only the correct option matches the plan command's function.
What role do modules play when running an Ansible playbook?
Explanation: Modules in Ansible represent reusable units that perform tasks from simple operations to complex system configuration. They do not provide hardware, encrypt files by default, or manage hardware monitoring like CPU temperature.
How can Terraform variables be set when running a configuration?
Explanation: Variables in Terraform are flexible and can be set in multiple ways, including files, environment variables, or directly through the command line. They are not restricted to the main resource file or OS kernel, nor are they inaccessible for user configuration.
What does it mean if an IaC tool like Ansible is idempotent?
Explanation: Idempotence ensures that repeating an operation leads to the same result, which is essential for reliable configuration management. Other options incorrectly describe randomness, duplication, or failure, which are not attributes of idempotence.
If you want to install a package on multiple servers using Ansible, what would you primarily use?
Explanation: Ansible playbooks automate tasks such as package installation by targeting hosts or host groups in the inventory. Manual installs and unrelated scripts do not utilize Ansible's automation. Editing the state file manually is not how tasks are applied in Ansible.