yandex: do not use cloud-config fileds due to possible collision

This commit is contained in:
Roman Mingazeev 2020-12-14 13:04:27 +03:00
parent d8277aa455
commit 354166350d
2 changed files with 7 additions and 7 deletions

View File

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

View File

@ -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))
}