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

[WIP] Add CloudInit Provider #3416

Closed
wants to merge 4 commits into from
Closed

[WIP] Add CloudInit Provider #3416

wants to merge 4 commits into from

Conversation

jen20
Copy link
Contributor

@jen20 jen20 commented Oct 5, 2015

This adds an initial version of a cloudinit provider which can be used to construct multipart, gzipped, base64 encoded configurations for use as userdata for various different clouds. It is currently presented as a work-in-progress in order to solicit feedback, but needs improved testing prior to merging.

Example

provider "cloudinit" {}

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

  part {
    # Note this is needed since the set does not maintain ordering and the config scripts are not commutative
    order = 2
    content_type = "text/x-shellscript"
    content = "${file("shellscript1.sh")}"
  }

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

  part {
    order = 3
    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:

--7e8c268155c51af5992d6f61fa35cc04afb47a4fb3ad3676d0339613fab8
Content-Type: text/x-shellscript

#!/usr/bin/env bash

touch /.testscript2

--7e8c268155c51af5992d6f61fa35cc04afb47a4fb3ad3676d0339613fab8
Content-Type: text/x-shellscript

#!/usr/bin/env bash

touch /.testscript1

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

#cloud-config

runcmd:
 - touch /testfile

--7e8c268155c51af5992d6f61fa35cc04afb47a4fb3ad3676d0339613fab8
Content-Type: text/cloud-config

#cloud-config

runcmd:
 - touch /testfile2

--7e8c268155c51af5992d6f61fa35cc04afb47a4fb3ad3676d0339613fab8--

TODO

  • Deal correctly with multi-part content header (not currently implemented)
  • Add resource tests for the config format
  • Fix up error messages to be reasonable and informative
  • Update documentation with resource
  • Document with GoDoc
  • Update ChangeLog

This adds an initial version of a cloudinit provider which can be used
to construct multipart, gzipped, base64 encoded configurations for use
as userdata for various different clouds.
@sthulb
Copy link

sthulb commented Oct 29, 2015

@jen20 Is this something you're still working on?
EDIT: replaced names :)

@radeksimko
Copy link
Member

@sthulb I am not, I was just tagging it properly.
@jen20 Opened the PR, so he's probably better person to answer.

@sthulb
Copy link

sthulb commented Oct 29, 2015

I misread, sorry @radeksimko

@chrusty
Copy link
Contributor

chrusty commented Nov 22, 2015

I just tried this out myself, and it definitely generates a multi-part userdata. I've not tried it in a launch-config yet, but it seems to be a well-implemented solution to me. Thanks!

@jen20
Copy link
Contributor Author

jen20 commented Nov 25, 2015

Closed in favour of the continuing work on #4061.

@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.

4 participants