Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cloudinit Multipart Configuration Resource #4095

Merged
merged 7 commits into from
Dec 21, 2015
Merged

Cloudinit Multipart Configuration Resource #4095

merged 7 commits into from
Dec 21, 2015

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Nov 28, 2015

This pull request is for a new resource in the template provider named template_cloudinit_config which renders multi-part cloudinit config templates from source files.

It has previously been worked on in #3416 (by me) and #4061 (by @sthulb), but prior to merging it would be good for someone else on the Terraform core team to review it.

Example

resource "template_cloudinit_config" "myconfig" {
  gzip = false
  base64_encode = true

  part {
    content_type = "text/x-shellscript"
    content = "${file("shellscript1.sh")}"
  }

  part {
    content_type = "text/x-shellscript"
    content = "${file("shellscript2.sh")}"
  }

  part {
    content_type = "text/cloud-config"
    merge_type = "list(append)+dict(recurse_array)+str()"
    content = "${file("cloudconfig.yaml")}"
  }
}

output "content" {
  value = "${cloudinit_config.myconfig.rendered}"
}

Output:

--MIMEBOUNDARY
Content-Type: text/x-shellscript

#!/usr/bin/env bash

touch /.testscript2

--MIMEBOUNDARY
Content-Type: text/x-shellscript

#!/usr/bin/env bash

touch /.testscript1

--MIMEBOUNDARY
Content-Type: text/cloud-config
X-Merge-Type: list(append)+dict(recurse_array)+str()

#cloud-config

runcmd:
 - touch /testfile

--MIMEBOUNDARY
Content-Type: text/cloud-config

#cloud-config

runcmd:
 - touch /testfile2

--MIMEBOUNDARY--

@apparentlymart
Copy link
Contributor

Hmm interesting... do you think this could just be a general multipart MIME encoder? It sure looks close at first glance... I'd be tempted to name it template_mime_multipart. 😀

@jen20
Copy link
Contributor Author

jen20 commented Nov 29, 2015

@apparentlymart sort of. It does have some additional behaviour that currently stops it being a generic multipart encoder, though I'm not opposed necessarily to the idea of generalising it:

  • checks are made as to the Content-Type of each part, and whether they are part of the list supported by CloudInit
  • headers which are specific to CloudInit (X-MergeType) are included as 'first class' options.

@jen20 jen20 added enhancement and removed core labels Nov 29, 2015
@sthulb
Copy link

sthulb commented Dec 7, 2015

@jen20 I've found an issue. I'll submit a PR against this branch

@jen20
Copy link
Contributor Author

jen20 commented Dec 8, 2015

Also see #4189 - this requires using a fork of the mime package until the change referenced there is merged into the Go standard library.

@apparentlymart apparentlymart changed the title Cloudinit Provider Cloudinit Multipart Configuration Resource Dec 8, 2015
@sthulb
Copy link

sthulb commented Dec 19, 2015

@jen20 is there any chance of getting this merged for the next release?

@phinze
Copy link
Contributor

phinze commented Dec 21, 2015

LGTM

jen20 and others added 7 commits December 21, 2015 13:32
This adds a new resource to template to generate multipart cloudinit
configurations to be used with other providers/resources.

The resource has the ability gzip and base64 encode the parts.
This is necessitated by new resources being added to the template
provider.
The original implmentation was missing headers to denote mime version &
content transfer encoding, this caused issues with EC2.

Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
Signed-off-by: Simon Thulbourn <simon+github@thulbourn.com>
jen20 added a commit that referenced this pull request Dec 21, 2015
New resource: Cloudinit Multipart Configuration
@jen20 jen20 merged commit 3cdcaf5 into master Dec 21, 2015
@jen20 jen20 deleted the cloudinit-provider branch December 21, 2015 18:50
@sthulb
Copy link

sthulb commented Dec 21, 2015

Thanks everyone. :)

@jen20
Copy link
Contributor Author

jen20 commented Dec 21, 2015

@sthulb This should be in 0.6.9, which is due imminently!

@sthulb
Copy link

sthulb commented Dec 21, 2015

@jen20 🎉

@sthulb
Copy link

sthulb commented Dec 21, 2015

Thanks for your help @jen20

@ghost
Copy link

ghost commented Apr 29, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@ghost ghost locked and limited conversation to collaborators Apr 29, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants