rancher / os

Tiny Linux distro that runs the entire OS as Docker containers
https://rancher.com/docs/os/v1.x/en/
Apache License 2.0
6.44k stars 655 forks source link

Cannot use multipart cloud-config #2367

Open mvisonneau opened 6 years ago

mvisonneau commented 6 years ago

It seems that cloud-init-execute doesn't support multi-parted cloud-config files :

time="2018-05-23T11:56:01Z" level=error msg="Unrecognized user-data
(Content-Type: multipart/mixed; boundary="MIMEBOUNDARY"
MIME-Version: 1.0^M
^M
--MIMEBOUNDARY^M
Content-Transfer-Encoding: 7bit^M
Content-Type: text/cloud-config^M
Mime-Version: 1.0^M
^M
#cloud-config

hostname: foo
^M
--MIMEBOUNDARY^M
Content-Transfer-Encoding: 7bit^M
Content-Type: text/cloud-config^M
Mime-Version: 1.0^M
^M
#cloud-config

locale: en_US.UTF-8
timezone: UTC
--MIMEBOUNDARY--^M

RancherOS Version: (ros os version)

1.3.0

Where are you running RancherOS? (docker-machine, AWS, GCE, baremetal, etc.)

AWS

kingsd041 commented 6 years ago

@mvisonneau Can you give more detailed steps? Where do you add multiple user data?

mvisonneau commented 6 years ago

👋 I pass a mime-multipart archive as my cloud-config file. I personally use the Terraform template_cloudinit_config data resource in order to build it :

data "template_cloudinit_config" "cloudinit" {
  gzip          = true
  base64_encode = true

  part {
    content_type = "text/cloud-config"
    content          = <<EOF
hostname: foo
EOF
  }

  part {
    content_type = "text/cloud-config"
    content          = <<EOF
locale: en_US.UTF-8
timezone: UTC
EOF
  }
}
kingsd041 commented 6 years ago

@mvisonneau Thank you for your feedback @niusmallnan We do not currently support mime-multipart archive. I launch a ubuntu instance on aws and set user-data:

Content-Type: multipart/mixed; boundary="==BOUNDARY=="
MIME-Version: 1.0

--==BOUNDARY==
Content-Type: text/cloud-boothook; charset="us-ascii"

#!/bin/bash
echo "test1" >> /opt/test1.config

--==BOUNDARY==
Content-Type: text/x-shellscript; charset="us-ascii"

#!/bin/bash
echo "test2" >> /opt/test2.config

--==BOUNDARY==--

Then I login to the instance to view the /opt directory, I can view test1.config and test2.config. But if I use the same steps to launch rancheros v1.4.1, the /opt directory is empty.

phillycheeze commented 5 years ago

The rancher quickstart repo for AWS (https://github.com/rancher/quickstart/tree/master/aws) uses the multi-part cloud-init configuration in terraform. It uses Ubuntu 18.04.

Ideally we would be able to swap it out with just the rancheros ami, but the error above prevents us from using that type of userdata.