purpleidea / mgmt

Next generation distributed, event-driven, parallel config management!
https://purpleidea.com/tags/mgmtconfig/
GNU General Public License v3.0
3.65k stars 314 forks source link

[LOVE] Support terraform resources with polling #318

Open purpleidea opened 6 years ago

purpleidea commented 6 years ago

Welcome:

This is a difficult patch for someone who has experience in golang, and some experience in mgmt or terraform. It is meant to encourage an mgmt hacker to get more deeply involved with mgmt. It will probably take you at least a week or more to complete.

Intro:

Mgmt is a relatively new tool written in golang. It doesn't have as many "cloud" resources as other tools like terraform. It would be helpful for terraform users to be able to get the advantages of the mgmt language with the addition of some of the terraform backends. We'd like to make many of the terraform resources available in mgmt. To implement this, you'll need to either recommend an alternate design, or use the one provided below.

Design:

You'll need to come up with a way of exposing terraform resources in mgmt. If there is a way to generate these via some sort of compatibility layer and/or mapping rather than building each one manually, that might be preferable. Unfortunately terraform doesn't have events, so initially, we'd want to have these resources default to polling. In the worst case scenario, we implement each resource manually.

Read the contributing tips: https://github.com/purpleidea/mgmt/blob/master/.github/PULL_REQUEST_TEMPLATE.md

Happy hacking, and ping me for questions!

Bonus/Future work:

jonathangold commented 6 years ago

I would like to work on this, if no one else already is.

jonathangold commented 6 years ago

A few thoughts on design.

Terraform uses a Resource type (https://github.com/hashicorp/terraform/blob/master/helper/resource/resource.go) to define methods for resources, and a Schema type (https://github.com/hashicorp/terraform/blob/master/helper/schema/schema.go) to define the resources' parameters.

Since all terraform resources are represented by those types, afaict, it should be possible to implement a compatibility layer. This would involve figuring out how to represent any terraform schema (map[string]string perhaps ) in mcl, and calling the methods defined in the (terraform) Resource type from Validate() and CheckApply().