Truth in IT
    • Sign In
    • Register
        • Videos
        • Channels
        • Pages
        • Galleries
        • News
        • Events
        • All
Truth in IT Truth in IT
  • Data Management ▼
    • Converged Infrastructure
    • DevOps
    • Networking
    • Storage
    • Virtualization
  • Cybersecurity ▼
    • Application Security
    • Backup & Recovery
    • Data Security
    • Identity & Access Management (IAM)
    • Zero Trust
    • Compliance & GRC
    • Endpoint Security
  • Cloud ▼
    • Hybrid Cloud
    • Private Cloud
    • Public Cloud
  • Webinar Library
  • TiPs
  • DRAW
  • CPE

HashiCorp: Using Terraform with Ansible for Configuration Management

HashiCorp
10/15/2026
0 (0%)
Share
  • Comments
  • Download
  • Transcript
Report Like Favorite
  • Share/Embed
  • Email
Link
Embed

Transcript


TL;DR

  • Terraform handles infrastructure provisioning, but post-provisioning configuration tasks — package installation, file configuration, database seeding — often require a dedicated tool like Ansible, especially at scale.
  • Whether to combine provisioning and configuration management in one pipeline or keep them separate depends on how tightly coupled the dependencies are; always build an escape hatch to run each stage independently.
  • Integrating Terraform with Ansible Automation Platform requires manual bootstrapping of credentials, job templates, and inventories in AAP before Terraform can reference them, creating a hybrid automated/manual workflow.
  • A stale SSH key pair caused a mid-stream failure, illustrating the real risk of managing dependencies that span Terraform state and external platforms — changes in one must be manually propagated to the other.
  • User data scripts are convenient for small demos but lack native completion signaling and idempotency guarantees, making Ansible a more robust choice for configuring infrastructure at any meaningful scale.
  • The choice between Terraform-first and Ansible-first workflows is largely driven by team familiarity and existing toolchain investment; neither approach is universally correct, and most mature environments use both.

Terraform and Ansible: Why Both Tools Are Needed

Episode 12 of the "Getting Into Terraform" series tackles one of the most practical and frequently encountered challenges in infrastructure automation: what happens after Terraform provisions a resource? Hosts Rosemary Wang and Richard Boyd explore the boundary between infrastructure provisioning and configuration management, explaining why Terraform alone is often insufficient for post-provisioning tasks such as installing packages, configuring networking, or seeding database schemas. The session opens with a substantive discussion on whether provisioning and configuration management pipelines should be kept separate or combined. The hosts argue that the answer is context-dependent: tightly coupled dependencies between infrastructure attributes and configuration steps favor a unified pipeline, while loosely coupled scenarios benefit from separation. A key insight offered is the importance of always building an "escape hatch" — the ability to run provisioning independently of configuration management — so that teams are never forced to execute an entire pipeline just to push a configuration change.

Ansible Automation Platform Integration Walkthrough

The bulk of the episode is a live, unscripted walkthrough of integrating Terraform with Red Hat's Ansible Automation Platform (AAP). The hosts demonstrate the end-to-end setup required to trigger an Ansible playbook against an AWS EC2 instance provisioned by Terraform. This includes configuring SSH credentials in AAP, creating a project linked to a Git repository containing the playbook, defining a job template, and building an inventory of target hosts. The session surfaces a classic chicken-and-egg problem: credentials, job templates, and inventories must be configured in AAP before Terraform can reference them, creating a manual bootstrapping dependency that sits outside the automated pipeline. The hosts encounter a real-world failure mid-stream when AAP cannot reach the EC2 host due to a stale SSH key pair — the private key had been regenerated by Terraform but not updated in AAP. They resolve this by outputting the private key from Terraform state using a base64-encoded sensitive output, then manually updating the credential in AAP. This friction point becomes a teaching moment about the risks of managing dependencies that span both automated and manual configuration boundaries.

Lessons Learned and Practical Guidance

The closing segment distills the session's hard-won lessons into actionable guidance. The hosts emphasize that mutable configuration management — making in-place changes to running infrastructure — is a legitimate and common pattern, even if immutable infrastructure via golden images is the preferred long-term goal. They acknowledge that user data scripts are a viable shortcut for small demos but do not scale well, citing the lack of native completion signaling and the complexity of managing idempotency across many hosts. The episode also highlights that the choice between Terraform-first and Ansible-first workflows often comes down to team familiarity and existing toolchain investment rather than a universal best practice. A recurring theme is the importance of being deliberate about automation boundaries: clearly delineating what is fully automated, what requires manual intervention, and where those handoffs occur. The hosts close by noting that the AAP provider for Terraform is a relatively new integration that has not previously been demonstrated live, making this episode a first-of-its-kind walkthrough for the series. The next stream is scheduled for August 11th and will likely cover Terraform module testing.

Chapters

0:00 - Introduction and Series Context
1:23 - The Provisioning vs. Configuration Problem
6:05 - One Pipeline or Two? Audience Q&A
11:04 - Introducing Ansible Automation Platform
13:47 - Why User Data Scripts Don't Scale
58:02 - Configuring AAP: Projects and Job Templates
112:11 - Running the Job and Debugging SSH Failure
113:55 - Extracting Private Key from Terraform State
119:36 - Automation Boundaries and Manual Handoffs
121:44 - Recap and Closing Thoughts

Key Quotes

1:23 "The really big problem that people tend to encounter at some point is basically how do you integrate Terraform with every other workflow that you need to work with."
10:05 "You should offer an escape hatch, right? If you are letting yourself combine configuration management and provisioning in one pipeline, make sure you give yourself an escape hatch to just run the provisioning piece as you need to."
14:07 "My biggest complaint about user data scripts is that there isn't like a good native way to know when it's done or has, like, when it's no longer executing."
115:11 "This is why I don't like doing like half things in Terraform and half things out of Terraform. In my opinion, this is where things go horribly awry, because you've configured some things in Terraform, but you have dependencies outside of Terraform."
121:23 "Just make sure that as you think about this, though, you're more deliberate about where you are actually automating versus where these steps are manual."
122:29 "It's not one or the other, but most folks try to do everything as immutable as possible and not do mutable changes like with configuration management."

FAQ

When should I use Terraform versus Ansible for managing infrastructure?

Terraform is best suited for provisioning and lifecycle management of infrastructure resources — creating, updating, and destroying cloud resources declaratively. Ansible excels at mutable, in-place configuration tasks such as installing packages, configuring files, or seeding databases on already-running infrastructure. Most mature environments use both: Terraform provisions the resource, and Ansible configures it afterward. The decision of whether to run them in one pipeline or separate pipelines depends on how tightly coupled the provisioning attributes are to the configuration steps.

What is the Ansible Automation Platform (AAP) provider for Terraform, and how does it work?

The AAP provider for Terraform allows you to trigger Ansible job templates directly from a Terraform configuration. To use it, you first configure credentials, a project (linked to a Git repository containing your playbook), a job template, and an inventory of target hosts inside AAP. Terraform then references these resources — typically via data sources — and can launch a job against a provisioned host as part of the apply workflow. There is a bootstrapping dependency: the AAP objects must exist before Terraform can reference them, which means some initial setup in AAP is manual.

Why shouldn't I just use user data scripts instead of Ansible for post-provisioning configuration?

User data scripts are convenient for simple, one-time setups in demos or small environments, but they have significant limitations at scale. They lack native signaling for completion or failure — you typically have to implement workarounds like writing a sentinel file to S3 or polling the filesystem. They are also difficult to make idempotent, meaning running them multiple times can produce inconsistent results. Ansible, by contrast, is designed for idempotent, repeatable configuration management and provides structured output and error handling, making it far more reliable for production use across many hosts.


Categories:
  • » Cybersecurity » Application Security
  • » Data Management » DevOps
  • » Cybersecurity » Cloud Security
  • » Data Protection
Channels:
News:
Events:
Tags:
  • Infrastructure as Code
  • DevSecOps
  • Cloud Security
  • How-To
  • Technical Deep Dive
  • Demo
  • Best Practices
  • Terraform and Ansible integration
  • Configuration management
  • Ansible Automation Platform
  • Mutable vs. immutable infrastructure
  • CI
  • CD pipeline design
Show more Show less

Browse videos

  • Related
  • Featured
  • By date
  • Most viewed
  • Top rated
  •  

              Video's comments: HashiCorp: Using Terraform with Ansible for Configuration Management

              View CPE Certificates

              Upcoming 360 View Events

              • Nov
                19

                Securing the Microsoft Enterprise: Strengthening Configuration Management, Identity Security, and Data Protection

                11/19/202601:00 PM ET
                More events

                XStreaminars (watch here)

                • Nov
                  12

                  Leaving VMware Means Leaving vSAN: Your VMware Exit Is Really a Storage Decision

                  11/12/202601:00 PM ET
                  More events

                  Industry Events (Sponsor Hosted)

                  • Nov
                    12

                    Hands-On Workshop: Connecting On-Prem Data to Databricks Using MinIO AIStor (Americas)

                    11/12/202601:00 PM ET
                    • Nov
                      18

                      Hands-On Workshop: Connecting On-Prem Data to Databricks via MinIO AIStor (International)

                      11/18/202608:00 AM ET
                      • Nov
                        19

                        Zendesk Deep Dive: Get the work done faster with Employee Service AI Agents

                        11/19/202601:00 PM ET
                        • Nov
                          19

                          A Deep Dive into Muse, Dots, and Duet's Impact on Your Website

                          11/19/202601:00 PM ET
                          • Dec
                            02

                            Skylight en acción: salvaguardando la IA más allá del usuario.

                            12/02/202604:00 AM ET
                            More events

                            Upcoming Webinar Calendar

                            • 11/12/2026
                              01:00 PM
                              11/12/2026
                              Leaving VMware Means Leaving vSAN: Your VMware Exit Is Really a Storage Decision
                              https://www.truthinit.com/index.php/channel/2192/leaving-vmware-means-leaving-vsan-your-vmware-exit-is-really-a-storage-decision/
                            • 11/12/2026
                              01:00 PM
                              11/12/2026
                              Hands-On Workshop: Connecting On-Prem Data to Databricks Using MinIO AIStor (Americas)
                              https://www.truthinit.com/index.php/channel/2202/hands-on-workshop-connecting-on-prem-data-to-databricks-using-minio-aistor-americas/
                            • 11/18/2026
                              08:00 AM
                              11/18/2026
                              Hands-On Workshop: Connecting On-Prem Data to Databricks via MinIO AIStor (International)
                              https://www.truthinit.com/index.php/channel/2194/hands-on-workshop-connecting-on-prem-data-to-databricks-via-minio-aistor-international/
                            • 11/19/2026
                              01:00 PM
                              11/19/2026
                              Securing the Microsoft Enterprise: Strengthening Configuration Management, Identity Security, and Data Protection
                              https://www.truthinit.com/index.php/channel/2076/securing-the-microsoft-enterprise-strengthening-configuration-management-identity-security-and-data-protection/
                            • 11/19/2026
                              01:00 PM
                              11/19/2026
                              Zendesk Deep Dive: Get the work done faster with Employee Service AI Agents
                              https://www.truthinit.com/index.php/channel/2181/zendesk-deep-dive-get-the-work-done-faster-with-employee-service-ai-agents/
                            • 11/19/2026
                              01:00 PM
                              11/19/2026
                              A Deep Dive into Muse, Dots, and Duet's Impact on Your Website
                              https://www.truthinit.com/index.php/channel/2228/a-deep-dive-into-muse-dots-and-duets-impact-on-your-website/
                            • 12/02/2026
                              04:00 AM
                              12/02/2026
                              Skylight en acción: salvaguardando la IA más allá del usuario.
                              https://www.truthinit.com/index.php/channel/2147/skylight-en-acción-salvaguardando-la-ia-más-allá-del-usuario/
                            • 12/03/2026
                              01:00 PM
                              12/03/2026
                              CISO Insights: Steering Cybersecurity Strategies in an AI-Driven Era
                              https://www.truthinit.com/index.php/channel/2231/ciso-insights-steering-cybersecurity-strategies-in-an-ai-driven-era/
                            • 01/19/2027
                              04:00 AM
                              01/19/2027
                              Skylight in Aktion: Gewährleisten Sie KI-Schutz über den Benutzer hinaus
                              https://www.truthinit.com/index.php/channel/2176/skylight-in-aktion-gewährleisten-sie-ki-schutz-über-den-benutzer-hinaus/
                            • 01/19/2027
                              02:00 PM
                              01/19/2027
                              HUMAN Dialogue: Embracing the Rise of the Empowered AI Consumer.
                              https://www.truthinit.com/index.php/channel/2160/human-dialogue-embracing-the-rise-of-the-empowered-ai-consumer/
                            • 03/18/2027
                              01:00 PM
                              03/18/2027
                              Securing Access for People, Partners and AI Agents
                              https://www.truthinit.com/index.php/channel/2251/securing-access-for-people-partners-and-ai-agents/
                            • 06/17/2027
                              01:00 PM
                              06/17/2027
                              Stop the Leak: Data Loss Prevention for the AI Era
                              https://www.truthinit.com/index.php/channel/955/360view-stop-the-leak-data-loss-prevention-for-the-ai-era/
                            • 08/19/2027
                              01:00 PM
                              08/19/2027
                              Who Has Access to What...and Should They?
                              https://www.truthinit.com/index.php/channel/2252/who-has-access-to-what-and-should-they/
                            • 10/21/2027
                              01:00 PM
                              10/21/2027
                              After VMware: Building the Private Cloud You Actually Want
                              https://www.truthinit.com/index.php/channel/2253/after-vmware-building-the-private-cloud-you-actually-want/
                            • 11/18/2027
                              01:00 PM
                              11/18/2027
                              Assume Breach, Prove Recovery
                              https://www.truthinit.com/index.php/channel/2254/assume-breach-prove-recovery/
                            • 12/16/2027
                              01:00 PM
                              12/16/2027
                              The Self-Running Service Desk
                              https://www.truthinit.com/index.php/channel/2255/the-self-running-service-desk/
                            Truth in IT
                            • Sponsor
                            • About Us
                            • Terms of Service
                            • Privacy Policy
                            • Contact Us
                            • Preference Management
                            Desktop version
                            Standard version