Live data from Hacker News

Ask HN: What is the real difference between Terraform and Ansible?

news.ycombinator.com

61–67 of 67 posts

Re: Ask HN: What is the real difference between Terraform and Ansible?

#61

Earlier quoted context omitted.

My advice would be to avoid Ansible for that sort of thing like the plague. All the nice things like idempotency and having the same script for setting things up and tearing them down no longer function when using those modules. Essentially you need to 1. do the checks to ensure your playbook won't just create a new set of VMs every time it's run if they already exist 2. maintain a teardown playbook alongside your se…

I think you're exagerating. I use Ansible to provision dev environments on each PR, it works fine, every time a deployment occurs Ansible will deploy if required, otherwise proceeded with the deployment. Destroying the environment is done separate, triggered by a webhook once the PR is closed.

If you're just provisioning software on an individual server, then sure. I agree. It kinda works okay.

What I'm talking about is using the cloud modules to spin up servers, and god help you, entire VPC set ups.

Re: Ask HN: What is the real difference between Terraform and Ansible?

#62

Earlier quoted context omitted.

I think you're exagerating. I use Ansible to provision dev environments on each PR, it works fine, every time a deployment occurs Ansible will deploy if required, otherwise proceeded with the deployment. Destroying the environment is done separate, triggered by a webhook once the PR is closed.

If you're just provisioning software on an individual server, then sure. I agree. It kinda works okay. What I'm talking about is using the cloud modules to spin up servers, and god help you, entire VPC set ups.

Each PR will provision a new server and then configure/deploy.

Re: Ask HN: What is the real difference between Terraform and Ansible?

#63

Terraform is for building infrastructure, you know foundations, skyscrapers, streets. Build an empty restaurant with a giant yellow excavator (Terraform) Ansible, Chef are for building configuration, you know menus, staff schedules, grocery lists. Ensure a restaurant is configured correctly to serve customers with its wait staff (Ansible) You can use an excavator to configure the stuff inside the restaurant. People d…

That's a great analogy. Breaking down concepts like this helps a lot more than most people realise...

Re: Ask HN: What is the real difference between Terraform and Ansible?

#64
I know I'm late to comment, so this will probably get buried, but I think a key to understanding Terraform and why it is different is to understand that it's an implementation of the Reconciler Pattern. This is a more useful distinction than the usual declarative vs imperative contrast that is usually brought up.

The Reconciler Pattern basically means:

* there is some notion of "expected" state, which is what you define (declaritively) in the configuration

* there is some "actual" state, which is basically what is running at whatever cloud service, etc. you are dealing with.

* the reconciler's job is to query the actual state, compare it to the expected state, calculate the difference (usually in terms of a graph), then make whatever changes it needs to to bring "actual" in line with "expected".

Kubernetes, SaltStack, and others implement the same pattern (just on different levels of resources) and it's becoming increasingly common and important to understand if you're working with cloud stuff.

https://www.oreilly.com/library/view/cloud-native-infrastruc...

Re: Ask HN: What is the real difference between Terraform and Ansible?

#65

Earlier quoted context omitted.

If you're just provisioning software on an individual server, then sure. I agree. It kinda works okay. What I'm talking about is using the cloud modules to spin up servers, and god help you, entire VPC set ups.

Each PR will provision a new server and then configure/deploy.

So wait, you make a playbook per individual server instance? Why?

Re: Ask HN: What is the real difference between Terraform and Ansible?

#66

Earlier quoted context omitted.

Each PR will provision a new server and then configure/deploy.

So wait, you make a playbook per individual server instance? Why?

He didn't say that. He presumably uses one playbook that creates vms and provisions the software for every PR. With ansible this can be idempotent and creating vms is by default idempotent.

Re: Ask HN: What is the real difference between Terraform and Ansible?

#67
post #16

There 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…

This is a good overview, but notice how hazy these different categories are around the edges. > not only create servers, but also databases, caches, load balancers, queues These things are, I would say unquestionably "infrastructure". > firewall settings, routing rules, Secure Sockets Layer (SSL) certificates These things are more or less configuration, basically files that exist on the above. And yet, as you say, it…

> > firewall settings, routing rules, Secure Sockets Layer (SSL) certificates

> These things are more or less configuration, basically files that exist on the above.

Part of the different perspective feels like managed cloud vs on prem.

In the former, these are all actually things to be created, albeit as an abstraction on the underlying implementation. Which you don't have access to.

In the latter, they're configurations on things you have access to.

Post reply on HN