Terraform + Docker Machine?

420 views
Skip to first unread message

Matthew Mueller

unread,
Jun 20, 2016, 9:30:19 AM6/20/16
to Terraform
Hi all,

I'm looking for some guidance on what I thought would be a pretty common use case:

1. Provision a compute resource (using GCE but could be EC2) with an image that has the docker daemon running (CoreOS right now, but I'd like to eventually try RancherOS)
2. Start up some default docker containers (ex. Agents for Rancher)

Unfortunately, I'm stuck right now. Docker Machine handles this wonderfully, but I'm finding myself trying to replicate it's steps in Terraform. I was wondering if anyone has built this out in Terraform or if there's a nice way to make the two work together.

Thanks!

Matt

Matthew Mueller

unread,
Jun 20, 2016, 9:35:38 AM6/20/16
to Terraform
Ultimately I think it's going to be some combination of the google, tls and docker providers, but I'm having a real hard time getting this setup.

David Adams

unread,
Jun 20, 2016, 9:58:22 AM6/20/16
to terrafo...@googlegroups.com
I haven't worked with the TLS or Docker providers at all, but you can pull off most any sequence of events using the local-exec, remote-exec, and file provisioners along with the null resource. If there's not a reason to use only Terraform for the project, don't restrict yourself to just what it provides. Sometimes throwing other tools in to do some of the connecting steps makes things a lot simpler. Most important thing is to take it step by step, add one thing at a time, try out stuff to be sure you understand it, and test a full destroy/apply cycle as you go to build confidence. The greatest thing about Terraform for me is how easy it makes it to just experiment.

What specific problems are you running into?


--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/terraform-tool/b16c2366-7926-4b43-985c-d9e89a824446%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Matthew Mueller

unread,
Jun 20, 2016, 10:34:27 AM6/20/16
to Terraform
Thanks for the great info. I took a look at the null resource, but I wasn't sure how to configure it for the destroy case that you mentioned. Is there some lifecycle event I can hook into to implement setup and teardown commands?

Not running into anything in particular, mostly just trying to plan out how this would even work, but it seems like terraform only handles lifecycle events properly with it's providers. But I'm pretty new to terraform so I'm probably missing something.

David Adams

unread,
Jun 20, 2016, 12:47:23 PM6/20/16
to terrafo...@googlegroups.com
Good point. On a tangent I would love to see more hooks to call out to local/remote scripts or other things at various points: before/after plan, apply, destroy, change would all be useful. Some of these I've implemented with a Rakefile wrapper, but that can't inject things in the middle of the process.

On Mon, Jun 20, 2016 at 9:34 AM, Matthew Mueller <mattm...@gmail.com> wrote:
Thanks for the great info. I took a look at the null resource, but I wasn't sure how to configure it for the destroy case that you mentioned. Is there some lifecycle event I can hook into to implement setup and teardown commands?

Not running into anything in particular, mostly just trying to plan out how this would even work, but it seems like terraform only handles lifecycle events properly with it's providers. But I'm pretty new to terraform so I'm probably missing something.

--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
 
GitHub Issues: https://github.com/hashicorp/terraform/issues
IRC: #terraform-tool on Freenode
---
You received this message because you are subscribed to the Google Groups "Terraform" group.
To unsubscribe from this group and stop receiving emails from it, send an email to terraform-too...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages