<!-- mobian-agent-page publisher="dailydev" canonical="https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo" -->

---
title: Terraform vs Ansible? Just Use Both! | daily.dev
description: A homelab-focused walkthrough comparing Terraform/OpenTofu and Ansible, arguing they should be used together rather than as competitors. Terraform/OpenTofu...
canonical: https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo
twitter:card: summary_large_image
twitter:site: @dailydotdev
og:type: website
og:site_name: daily.dev
og:title: Terraform vs Ansible? Just Use Both! | daily.dev
og:description: A homelab-focused walkthrough comparing Terraform/OpenTofu and Ansible, arguing they should be used together rather than as competitors. Terraform/OpenTofu...
og:url: https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo
og:image: https://api.daily.dev/og/posts/8tMalQWpO.png
og:image:alt: Terraform vs Ansible? Just Use Both!
og:image:width: 1200
og:image:height: 630
og:locale: en
---

> ## Documentation Index
> Fetch the complete documentation index at: https://daily.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Terraform vs Ansible? Just Use Both!

**[Christian Lempa](https://daily.dev/sources/christianlempa)** · 19 min read · 5 upvotes · 0 comments

## Summary

A homelab-focused walkthrough comparing Terraform/OpenTofu and Ansible, arguing they should be used together rather than as competitors. Terraform/OpenTofu excels at managing the full lifecycle of infrastructure resources (VMs, DNS records, dependent resources) via a state file and dependency graph, while Ansible is better suited for operational tasks and configuration management on existing systems via agentless SSH connections. The workflow demonstrated uses Terraform/OpenTofu to provision Proxmox VMs and related resources (DNS, NetBox entries), then hands off to Ansible for OS-level package installation and configuration. An AI agent is used to generate Terraform resource files and Ansible playbook entries. The video is sponsored by Twingate, a zero trust network access (ZTNA) tool that integrates with Terraform for managing access policies as code.

## Full article

daily.dev links to this article rather than hosting it. Read it at the original source: <https://www.youtube.com/watch?v=q-Dc19Jk_KY>

## Questions this post answers

### When should I use Terraform or OpenTofu versus Ansible for managing my infrastructure?

Terraform or OpenTofu is best for managing the full lifecycle of resources such as virtual machines, DNS records, and IPAM entries, since it tracks state and builds a dependency graph to plan creation, change, or destruction. Ansible is better for operational and configuration tasks like installing packages, restarting services, or changing settings on existing systems, since it has no persistent state file and simply executes tasks in order over SSH.

_Anyone weighing infrastructure tooling choices can compare real Terraform and Ansible workflows on daily.dev._

### Why doesn't Ansible need a state file the way Terraform does?

Ansible does not maintain a persistent state file because it executes tasks defined in playbooks in sequence and inspects the current state of target systems only when the playbook runs, changing something only when necessary. This makes it flexible when servers are modified outside of Ansible, but it does not remember what it did in previous runs, unlike Terraform which stores a mapping of configuration to real infrastructure in a state file.

_Developers debugging configuration drift can dig into how Ansible and Terraform track state differently on daily.dev._

### Can Ansible and Terraform both be used to create infrastructure like Proxmox virtual machines?

Yes, both tools can create Proxmox virtual machines: OpenTofu and Terraform have a Proxmox provider, and Ansible has a community collection that can also create VMs and LXC containers. The recommended approach is to use Terraform or OpenTofu for full-lifecycle resource management, and reserve Ansible for operating-system-level configuration such as installing the Prometheus node exporter or QEMU guest agent after the VM is provisioned.

_Teams designing Proxmox home lab automation can weigh these tool tradeoffs directly on daily.dev._

---

Tags: [#terraform](https://daily.dev/tags/terraform), [#iac](https://daily.dev/tags/iac), [#ansible](https://daily.dev/tags/ansible), [#proxmox](https://daily.dev/tags/proxmox), [#opentofu](https://daily.dev/tags/opentofu)

[View this post on daily.dev](https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo)

```json
{"@context":"https://schema.org","@graph":[{"@type":"Organization","@id":"https://daily.dev/#organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180},"sameAs":["https://twitter.com/dailydotdev","https://github.com/dailydotdev","https://www.linkedin.com/company/daily-dev-ltd"]},{"@type":"WebSite","@id":"https://daily.dev/#website","url":"https://daily.dev","name":"daily.dev","publisher":{"@id":"https://daily.dev/#organization"},"potentialAction":{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https://daily.dev/search?q={search_term_string}"},"query-input":"required name=search_term_string"}}]}
{"@context":"https://schema.org","@type":"TechArticle","headline":"Terraform vs Ansible? Just Use Both!","url":"https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo","mainEntityOfPage":{"@type":"WebPage","@id":"https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo"},"datePublished":"2026-08-25T14:02:17.003Z","dateModified":"2026-09-13T20:59:48.178Z","description":"A homelab-focused walkthrough comparing Terraform/OpenTofu and Ansible, arguing they should be used together rather than as competitors. Terraform/OpenTofu...","image":"https://i.ytimg.com/vi/q-Dc19Jk_KY/sddefault.jpg","thumbnailUrl":"https://i.ytimg.com/vi/q-Dc19Jk_KY/sddefault.jpg","isAccessibleForFree":true,"articleSection":"Christian Lempa","inLanguage":"en","publisher":{"@type":"Organization","name":"daily.dev","url":"https://daily.dev","logo":{"@type":"ImageObject","url":"https://daily.dev/apple-touch-icon.png","width":180,"height":180}},"author":{"@type":"Organization","name":"Christian Lempa","logo":"https://media.daily.dev/image/upload/s--r09bzzis--/f_auto/v1723788767/logos/christianlempa","url":"https://daily.dev/sources/christianlempa"},"commentCount":0,"discussionUrl":"https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo","interactionStatistic":[{"@type":"InteractionCounter","interactionType":{"@type":"LikeAction"},"userInteractionCount":5},{"@type":"InteractionCounter","interactionType":{"@type":"CommentAction"},"userInteractionCount":0}],"keywords":"terraform,iac,ansible,proxmox,opentofu","timeRequired":"PT19M","video":{"@type":"VideoObject","name":"Terraform vs Ansible? Just Use Both!","description":"A homelab-focused walkthrough comparing Terraform/OpenTofu and Ansible, arguing they should be used together rather than as competitors. Terraform/OpenTofu...","thumbnailUrl":"https://i.ytimg.com/vi/q-Dc19Jk_KY/sddefault.jpg","uploadDate":"2026-08-25T14:02:17.003Z","duration":"PT19M","url":"https://api.daily.dev/r/8tMalQWpO","embedUrl":"https://www.youtube.com/embed/q-Dc19Jk_KY"}}
{"@context":"https://schema.org","@type":"BreadcrumbList","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https://daily.dev"},{"@type":"ListItem","position":2,"name":"Christian Lempa","item":"https://daily.dev/sources/christianlempa"},{"@type":"ListItem","position":3,"name":"Terraform vs Ansible? Just Use Both!"}]}
{"@context":"https://schema.org","@type":"FAQPage","@id":"https://daily.dev/posts/terraform-vs-ansible-just-use-both--8tmalqwpo#faq","mainEntity":[{"@type":"Question","name":"When should I use Terraform or OpenTofu versus Ansible for managing my infrastructure?","acceptedAnswer":{"@type":"Answer","text":"Terraform or OpenTofu is best for managing the full lifecycle of resources such as virtual machines, DNS records, and IPAM entries, since it tracks state and builds a dependency graph to plan creation, change, or destruction. Ansible is better for operational and configuration tasks like installing packages, restarting services, or changing settings on existing systems, since it has no persistent state file and simply executes tasks in order over SSH. Anyone weighing infrastructure tooling choices can compare real Terraform and Ansible workflows on daily.dev."}},{"@type":"Question","name":"Why doesn't Ansible need a state file the way Terraform does?","acceptedAnswer":{"@type":"Answer","text":"Ansible does not maintain a persistent state file because it executes tasks defined in playbooks in sequence and inspects the current state of target systems only when the playbook runs, changing something only when necessary. This makes it flexible when servers are modified outside of Ansible, but it does not remember what it did in previous runs, unlike Terraform which stores a mapping of configuration to real infrastructure in a state file. Developers debugging configuration drift can dig into how Ansible and Terraform track state differently on daily.dev."}},{"@type":"Question","name":"Can Ansible and Terraform both be used to create infrastructure like Proxmox virtual machines?","acceptedAnswer":{"@type":"Answer","text":"Yes, both tools can create Proxmox virtual machines: OpenTofu and Terraform have a Proxmox provider, and Ansible has a community collection that can also create VMs and LXC containers. The recommended approach is to use Terraform or OpenTofu for full-lifecycle resource management, and reserve Ansible for operating-system-level configuration such as installing the Prometheus node exporter or QEMU guest agent after the VM is provisioned. Teams designing Proxmox home lab automation can weigh these tool tradeoffs directly on daily.dev."}}]}
```

