IaC Fundamentals: Terraform & Ansible Vocabulary
A beginner-friendly introduction to the core vocabulary of Infrastructure as Code: Terraform basics, Ansible playbooks, IaC documentation, and drift terminology, explained in plain language.
Frequently Asked Questions
What exactly is a 'Provider' in Terraform? I've seen it mentioned a lot.
In Terraform, a Provider represents an infrastructure service like AWS, Azure, or Google Cloud. It allows Terraform to interact with that service, understanding its APIs and resources. Essentially, the provider bridges the gap between your Terraform configuration and the cloud platform's services.
Can you explain 'state' in Terraform? Why is it so important?
'State' is a file (typically `.terraform/state.tfstate`) that Terraform uses to track the current infrastructure resources it manages. It contains information about each resource, its attributes, and its relationships – this allows Terraform to make changes predictably and consistently without needing constant API calls.
What's the difference between a 'module' and an 'inventory' in Ansible?
An Ansible module is a reusable unit of configuration code, often written in Python, that performs a specific task like creating a file or installing a package. An inventory defines the target machines (hosts) where you want to execute your Ansible playbooks; it lists the servers and their connection details.
What is 'playbook' in Ansible, and what does it do?
'Playbooks' are YAML files that define a series of tasks to be executed on target hosts. They specify which modules to use, the order in which they should run, and any variables needed for those tasks – think of it as a recipe for configuring your servers.
What is 'role' in Ansible? How does it relate to 'module'?
'Roles' are collections of related files and directories that represent a reusable configuration pattern. They often contain one or more modules, making them highly modular and easier to manage across multiple systems within your infrastructure.
What's the purpose of 'variables' in both Terraform and Ansible?
Variables are placeholders for values that can be defined once and reused throughout your configuration. In Terraform, they represent infrastructure attributes; in Ansible, they hold data used by modules or tasks – this promotes reusability and makes configurations more adaptable.
What is 'drift' in the context of Terraform state?
'Drift' occurs when changes made to your infrastructure outside of Terraform (e.g., manual modifications) cause discrepancies between the Terraform state file and the actual resources deployed. Terraform detects drift and prompts you to reconcile the differences to maintain consistency.
What is idempotency in Ansible playbooks?
Idempotency means that running an Ansible playbook multiple times should produce the same result as running it once. It ensures that your infrastructure configuration remains consistent, even if the playbook is executed repeatedly without unintended side effects.
Can you explain 'SSH Keys' and their role in Ansible?
'SSH keys' are a secure method of authentication for Ansible to connect to your target servers. By using SSH keys instead of passwords, you significantly enhance the security of your Ansible deployments and avoid password-related vulnerabilities.
What is 'Terraform Cloud' and how does it relate to my Terraform state?
'Terraform Cloud' is a managed service that allows you to store, version, and collaborate on your Terraform configurations. It securely stores your state file, enabling team collaboration and providing features like remote operations and secret management.