From 354166350d0ed3db624b23eff4db481a479c5703 Mon Sep 17 00:00:00 2001 From: Roman Mingazeev Date: Mon, 14 Dec 2020 13:04:27 +0300 Subject: [PATCH] yandex: do not use cloud-config fileds due to possible collision --- builder/yandex/cloud_init.go | 12 ++++++------ builder/yandex/step_create_instance.go | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/builder/yandex/cloud_init.go b/builder/yandex/cloud_init.go index f1e63b6ea..2a65b8c25 100644 --- a/builder/yandex/cloud_init.go +++ b/builder/yandex/cloud_init.go @@ -9,14 +9,14 @@ import ( ) const ( - defaultContentType = "text/cloud-config" - shellContentType = "text/x-shellscript" + defaultContentType = "text/cloud-config" + shellContentType = "text/x-shellscript" + multipartContentType = "multipart/mixed" ) const ( - cloudInitIPv6Config = `#cloud-config -bootcmd: -- [ sh, -c, '/usr/bin/env dhclient -6 -D LL -nw -pf /run/dhclient_ipv6.eth0.pid -lf /var/lib/dhcp/dhclient_ipv6.eth0.leases eth0' ] + cloudInitIPv6Config = `#!/usr/bin/env bash +dhclient -6 -D LL -nw -pf /run/dhclient_ipv6.eth0.pid -lf /var/lib/dhcp/dhclient_ipv6.eth0.leases eth0 ` ) @@ -24,7 +24,7 @@ bootcmd: func MergeCloudUserMetaData(usersData ...string) (string, error) { buff := new(bytes.Buffer) data := multipart.NewWriter(buff) - _, err := buff.WriteString(fmt.Sprintf("Content-Type: multipart/mixed; boundary=\"%s\"\r\n", data.Boundary())) + _, err := buff.WriteString(fmt.Sprintf("Content-Type: %s; boundary=\"%s\"\r\n", multipartContentType, data.Boundary())) if err != nil { return "", err } diff --git a/builder/yandex/step_create_instance.go b/builder/yandex/step_create_instance.go index f5f0f176b..83898f43f 100644 --- a/builder/yandex/step_create_instance.go +++ b/builder/yandex/step_create_instance.go @@ -221,7 +221,7 @@ func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) if !ok { oldUserData = "" } - instanceMetadata["user-data"], err = MergeCloudUserMetaData(oldUserData, cloudInitIPv6Config) + instanceMetadata["user-data"], err = MergeCloudUserMetaData(cloudInitIPv6Config, oldUserData) if err != nil { return StepHaltWithError(state, fmt.Errorf("Error merge user data configs: %s", err)) }