Ansible connects to remote servers to configure them, while Terraform calls cloud provider API’s to provision resources. For example, you can use Terraform to provision virtual machines, database instances, or Kubernetes clusters on AWS. Terraform does this via the AWS API. In my opinion, Terraform is better for provisioning because of the way it manages its own state. Terraform remembers what resources it created th…
Ansible has full integration with cloud providers API. It's actually better for managing instances and highly dynamic resources because it has much better state management than Terraform. If you (re)create some EC2 instances with Terraform. Terraform save the ID the first time they are created (in a state file that needs to be shared and keep in sync). It goes mental the next time it runs if any of the instances are…
Ask HN: What is the real difference between Terraform and Ansible?
21–30 of 67 posts
Re: Ask HN: What is the real difference between Terraform and Ansible?
#22Ansible connects to remote servers to configure them, while Terraform calls cloud provider API’s to provision resources. For example, you can use Terraform to provision virtual machines, database instances, or Kubernetes clusters on AWS. Terraform does this via the AWS API. In my opinion, Terraform is better for provisioning because of the way it manages its own state. Terraform remembers what resources it created th…
Ansible has full integration with cloud providers API. It's actually better for managing instances and highly dynamic resources because it has much better state management than Terraform. If you (re)create some EC2 instances with Terraform. Terraform save the ID the first time they are created (in a state file that needs to be shared and keep in sync). It goes mental the next time it runs if any of the instances are…
For example on AWS we use the s3 backend and a dynamodb table for locking. This way when terraform runs it will first acquire the lock, and then access the state on s3. And everyone is working on the same state.
Re: Ask HN: What is the real difference between Terraform and Ansible?
#23Ansible is an imperative way of setting up your cloud. You tell it to do certain things, install this package, copy this over there.
Hope it helps
Re: Ask HN: What is the real difference between Terraform and Ansible?
#24Very crudely, Ansible is like a YAML frontend to SSH, Terraform is like a TOML frontend to AWS CloudFormation.
Re: Ask HN: What is the real difference between Terraform and Ansible?
#25Terraform is a declarative way of setting up your cloud infrastructure. You specify the state you want your cloud to be in. Ansible is an imperative way of setting up your cloud. You tell it to do certain things, install this package, copy this over there. Hope it helps
by default you use Ansible modules/roles and specify the desired state.
E.g. have these packages installed, have these directories created/deleted.
Use cases not covered by modules can fallback to using shell commands
Re: Ask HN: What is the real difference between Terraform and Ansible?
#26Terraform is a declarative way of setting up your cloud infrastructure. You specify the state you want your cloud to be in. Ansible is an imperative way of setting up your cloud. You tell it to do certain things, install this package, copy this over there. Hope it helps
Re: Ask HN: What is the real difference between Terraform and Ansible?
#27Ansible is for 'inside' virtual machines or computers, Terraform is for 'outside' virtual machines or computers.
Inside a machine you might have software, configuration, assets. Outside a machine you might network connections, firewalls, disks, dns etc.
This isn't a comprehensive comparison, but when you start from nothing, it doesn't really help to do a syntax, provider or imperative vs. declarative.
Re: Ask HN: What is the real difference between Terraform and Ansible?
#28If you're familiar with Packer, then Packer is responsible for creating identical VM images which can be integrated to a CI pipeline and provisioned and baked using Ansible. This baked image is then deployed using Terraform.
Be advised that provisioning in Terraform during VM deployment is not recommended since it increases startup time of the machine. To perform ad hoc configuration management, you use Ansible.
You could very well use Ansible for managing and deploying cloud resources, but that's not what it's meant to do. Moreover, Ansible does not support the concept of state as does Terraform.
Re: Ask HN: What is the real difference between Terraform and Ansible?
#29Earlier quoted context omitted.
Ansible has full integration with cloud providers API. It's actually better for managing instances and highly dynamic resources because it has much better state management than Terraform. If you (re)create some EC2 instances with Terraform. Terraform save the ID the first time they are created (in a state file that needs to be shared and keep in sync). It goes mental the next time it runs if any of the instances are…
How does the coverage of APIs compare. Just AWS is a gigantic set of APIs. I see most of what I'd need in the Ansible Module Index but it doesn't seem like it covers all that is available.
Tracking AWS apis is a fulltime job and ansible for clouds just isn’t popular enough.
Re: Ask HN: What is the real difference between Terraform and Ansible?
#30There are five broad categories of IAC (Infrastructure as a Code) tools: a)Ad hoc scripts The most straightforward approach to automating anything is to write an ad hoc script. You take whatever task you were doing manually, break it down into discrete steps, use your favorite scripting language (e.g., Bash, Ruby, Python) to define each of those steps in code, and execute that script on your server b) Configuration m…