2019-03-26 08:29:15 -04:00
|
|
|
package yandex
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"errors"
|
|
|
|
"fmt"
|
|
|
|
"io/ioutil"
|
|
|
|
|
|
|
|
"github.com/c2h5oh/datasize"
|
2020-07-08 18:46:05 -04:00
|
|
|
"github.com/hashicorp/packer/builder"
|
2019-03-26 08:29:15 -04:00
|
|
|
"github.com/hashicorp/packer/common/uuid"
|
|
|
|
"github.com/hashicorp/packer/helper/multistep"
|
|
|
|
"github.com/hashicorp/packer/packer"
|
|
|
|
|
|
|
|
"github.com/yandex-cloud/go-genproto/yandex/cloud/compute/v1"
|
|
|
|
"github.com/yandex-cloud/go-genproto/yandex/cloud/vpc/v1"
|
|
|
|
ycsdk "github.com/yandex-cloud/go-sdk"
|
|
|
|
)
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
const StandardImagesFolderID = "standard-images"
|
|
|
|
|
2020-04-26 19:19:08 -04:00
|
|
|
type StepCreateInstance struct {
|
2019-04-09 10:46:41 -04:00
|
|
|
Debug bool
|
|
|
|
SerialLogFile string
|
2020-07-08 18:46:05 -04:00
|
|
|
|
|
|
|
GeneratedData *builder.GeneratedData
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
|
2019-04-04 09:17:51 -04:00
|
|
|
func createNetwork(ctx context.Context, c *Config, d Driver) (*vpc.Network, error) {
|
2019-03-26 08:29:15 -04:00
|
|
|
req := &vpc.CreateNetworkRequest{
|
|
|
|
FolderId: c.FolderID,
|
|
|
|
Name: fmt.Sprintf("packer-network-%s", uuid.TimeOrderedUUID()),
|
|
|
|
}
|
|
|
|
|
|
|
|
sdk := d.SDK()
|
|
|
|
|
|
|
|
op, err := sdk.WrapOperation(sdk.VPC().Network().Create(ctx, req))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = op.Wait(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := op.Response()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
network, ok := resp.(*vpc.Network)
|
|
|
|
if !ok {
|
|
|
|
return nil, errors.New("network create operation response doesn't contain Network")
|
|
|
|
}
|
|
|
|
return network, nil
|
|
|
|
}
|
|
|
|
|
2019-04-04 09:17:51 -04:00
|
|
|
func createSubnet(ctx context.Context, c *Config, d Driver, networkID string) (*vpc.Subnet, error) {
|
2019-03-26 08:29:15 -04:00
|
|
|
req := &vpc.CreateSubnetRequest{
|
|
|
|
FolderId: c.FolderID,
|
|
|
|
NetworkId: networkID,
|
|
|
|
Name: fmt.Sprintf("packer-subnet-%s", uuid.TimeOrderedUUID()),
|
|
|
|
ZoneId: c.Zone,
|
|
|
|
V4CidrBlocks: []string{"192.168.111.0/24"},
|
|
|
|
}
|
|
|
|
|
|
|
|
sdk := d.SDK()
|
|
|
|
|
|
|
|
op, err := sdk.WrapOperation(sdk.VPC().Subnet().Create(ctx, req))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
err = op.Wait(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := op.Response()
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
subnet, ok := resp.(*vpc.Subnet)
|
2019-03-26 08:29:15 -04:00
|
|
|
if !ok {
|
2019-04-09 10:46:41 -04:00
|
|
|
return nil, errors.New("subnet create operation response doesn't contain Subnet")
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
2019-04-09 10:46:41 -04:00
|
|
|
return subnet, nil
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
|
2019-04-04 09:17:51 -04:00
|
|
|
func getImage(ctx context.Context, c *Config, d Driver) (*Image, error) {
|
2019-03-26 08:29:15 -04:00
|
|
|
if c.SourceImageID != "" {
|
|
|
|
return d.GetImage(c.SourceImageID)
|
|
|
|
}
|
|
|
|
|
2019-09-10 10:52:42 -04:00
|
|
|
folderID := c.SourceImageFolderID
|
|
|
|
if folderID == "" {
|
|
|
|
folderID = StandardImagesFolderID
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
2019-09-10 10:52:42 -04:00
|
|
|
|
|
|
|
switch {
|
|
|
|
case c.SourceImageFamily != "":
|
|
|
|
return d.GetImageFromFolder(ctx, folderID, c.SourceImageFamily)
|
|
|
|
case c.SourceImageName != "":
|
|
|
|
return d.GetImageFromFolderByName(ctx, folderID, c.SourceImageName)
|
|
|
|
}
|
|
|
|
|
|
|
|
return &Image{}, errors.New("neither source_image_name nor source_image_family defined in config")
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
|
2020-04-26 19:19:08 -04:00
|
|
|
func (s *StepCreateInstance) Run(ctx context.Context, state multistep.StateBag) multistep.StepAction {
|
2019-03-26 08:29:15 -04:00
|
|
|
sdk := state.Get("sdk").(*ycsdk.SDK)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
2019-04-09 10:46:41 -04:00
|
|
|
config := state.Get("config").(*Config)
|
|
|
|
driver := state.Get("driver").(Driver)
|
2019-03-26 08:29:15 -04:00
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
ctx, cancel := context.WithTimeout(ctx, config.StateTimeout)
|
2019-04-04 09:17:51 -04:00
|
|
|
defer cancel()
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
sourceImage, err := getImage(ctx, config, driver)
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error getting source image for instance creation: %s", err))
|
|
|
|
}
|
|
|
|
|
|
|
|
if sourceImage.MinDiskSizeGb > config.DiskSizeGb {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Instance DiskSizeGb (%d) should be equal or greater "+
|
|
|
|
"than SourceImage disk requirement (%d)", config.DiskSizeGb, sourceImage.MinDiskSizeGb))
|
|
|
|
}
|
|
|
|
|
|
|
|
ui.Say(fmt.Sprintf("Using as source image: %s (name: %q, family: %q)", sourceImage.ID, sourceImage.Name, sourceImage.Family))
|
|
|
|
|
2019-04-04 09:17:51 -04:00
|
|
|
// create or reuse network configuration
|
2019-03-26 08:29:15 -04:00
|
|
|
instanceSubnetID := ""
|
2019-04-09 10:46:41 -04:00
|
|
|
if config.SubnetID == "" {
|
2019-04-04 09:17:51 -04:00
|
|
|
// create Network and Subnet
|
2019-03-26 08:29:15 -04:00
|
|
|
ui.Say("Creating network...")
|
2019-04-09 10:46:41 -04:00
|
|
|
network, err := createNetwork(ctx, config, driver)
|
2019-03-26 08:29:15 -04:00
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error creating network: %s", err))
|
|
|
|
}
|
|
|
|
state.Put("network_id", network.Id)
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
ui.Say(fmt.Sprintf("Creating subnet in zone %q...", config.Zone))
|
|
|
|
subnet, err := createSubnet(ctx, config, driver, network.Id)
|
2019-03-26 08:29:15 -04:00
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error creating subnet: %s", err))
|
|
|
|
}
|
|
|
|
instanceSubnetID = subnet.Id
|
|
|
|
// save for cleanup
|
2019-04-09 10:46:41 -04:00
|
|
|
state.Put("subnet_id", subnet.Id)
|
2019-03-26 08:29:15 -04:00
|
|
|
} else {
|
2019-04-09 10:46:41 -04:00
|
|
|
ui.Say("Use provided subnet id " + config.SubnetID)
|
|
|
|
instanceSubnetID = config.SubnetID
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
// Create an instance based on the configuration
|
|
|
|
ui.Say("Creating instance...")
|
|
|
|
|
2019-06-06 09:41:58 -04:00
|
|
|
instanceMetadata, err := config.createInstanceMetadata(string(config.Communicator.SSHPublicKey))
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error preparing instance metadata: %s", err))
|
|
|
|
}
|
2019-03-26 08:29:15 -04:00
|
|
|
|
|
|
|
// TODO make part metadata prepare process
|
2019-04-09 10:46:41 -04:00
|
|
|
if config.UseIPv6 {
|
2019-03-26 08:29:15 -04:00
|
|
|
// this ugly hack will replace user provided 'user-data'
|
|
|
|
userData := `#cloud-config
|
|
|
|
runcmd:
|
|
|
|
- [ sh, -c, '/sbin/dhclient -6 -D LL -nw -pf /run/dhclient_ipv6.eth0.pid -lf /var/lib/dhcp/dhclient_ipv6.eth0.leases eth0' ]
|
|
|
|
`
|
|
|
|
instanceMetadata["user-data"] = userData
|
|
|
|
}
|
|
|
|
|
|
|
|
req := &compute.CreateInstanceRequest{
|
2019-04-09 10:46:41 -04:00
|
|
|
FolderId: config.FolderID,
|
|
|
|
Name: config.InstanceName,
|
|
|
|
Labels: config.Labels,
|
|
|
|
ZoneId: config.Zone,
|
|
|
|
PlatformId: config.PlatformID,
|
2019-06-06 09:41:58 -04:00
|
|
|
SchedulingPolicy: &compute.SchedulingPolicy{
|
|
|
|
Preemptible: config.Preemptible,
|
|
|
|
},
|
2019-03-26 08:29:15 -04:00
|
|
|
ResourcesSpec: &compute.ResourcesSpec{
|
2019-04-09 10:46:41 -04:00
|
|
|
Memory: toBytes(config.InstanceMemory),
|
|
|
|
Cores: int64(config.InstanceCores),
|
2019-09-10 10:52:42 -04:00
|
|
|
Gpus: int64(config.InstanceGpus),
|
2019-03-26 08:29:15 -04:00
|
|
|
},
|
|
|
|
Metadata: instanceMetadata,
|
|
|
|
BootDiskSpec: &compute.AttachedDiskSpec{
|
2019-04-04 09:17:51 -04:00
|
|
|
AutoDelete: false,
|
2019-03-26 08:29:15 -04:00
|
|
|
Disk: &compute.AttachedDiskSpec_DiskSpec_{
|
|
|
|
DiskSpec: &compute.AttachedDiskSpec_DiskSpec{
|
2019-04-09 10:46:41 -04:00
|
|
|
Name: config.DiskName,
|
|
|
|
TypeId: config.DiskType,
|
|
|
|
Size: int64((datasize.ByteSize(config.DiskSizeGb) * datasize.GB).Bytes()),
|
2019-03-26 08:29:15 -04:00
|
|
|
Source: &compute.AttachedDiskSpec_DiskSpec_ImageId{
|
|
|
|
ImageId: sourceImage.ID,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
NetworkInterfaceSpecs: []*compute.NetworkInterfaceSpec{
|
|
|
|
{
|
|
|
|
SubnetId: instanceSubnetID,
|
|
|
|
PrimaryV4AddressSpec: &compute.PrimaryAddressSpec{},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|
|
|
|
|
2020-02-10 10:36:19 -05:00
|
|
|
if config.ServiceAccountID != "" {
|
|
|
|
req.ServiceAccountId = config.ServiceAccountID
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
if config.UseIPv6 {
|
2019-03-26 08:29:15 -04:00
|
|
|
req.NetworkInterfaceSpecs[0].PrimaryV6AddressSpec = &compute.PrimaryAddressSpec{}
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
if config.UseIPv4Nat {
|
2019-03-26 08:29:15 -04:00
|
|
|
req.NetworkInterfaceSpecs[0].PrimaryV4AddressSpec = &compute.PrimaryAddressSpec{
|
|
|
|
OneToOneNatSpec: &compute.OneToOneNatSpec{
|
|
|
|
IpVersion: compute.IpVersion_IPV4,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
op, err := sdk.WrapOperation(sdk.Compute().Instance().Create(ctx, req))
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error create instance: %s", err))
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
opMetadata, err := op.Metadata()
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error get create operation metadata: %s", err))
|
|
|
|
}
|
|
|
|
|
|
|
|
if cimd, ok := opMetadata.(*compute.CreateInstanceMetadata); ok {
|
|
|
|
state.Put("instance_id", cimd.InstanceId)
|
|
|
|
} else {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("could not get Instance ID from operation metadata"))
|
|
|
|
}
|
|
|
|
|
2019-03-26 08:29:15 -04:00
|
|
|
err = op.Wait(ctx)
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("Error create instance: %s", err))
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := op.Response()
|
|
|
|
if err != nil {
|
|
|
|
return stepHaltWithError(state, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
instance, ok := resp.(*compute.Instance)
|
|
|
|
if !ok {
|
|
|
|
return stepHaltWithError(state, fmt.Errorf("response doesn't contain Instance"))
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
state.Put("disk_id", instance.BootDisk.DiskId)
|
2019-12-13 14:57:01 -05:00
|
|
|
// instance_id is the generic term used so that users can have access to the
|
|
|
|
// instance id inside of the provisioners, used in step_provision.
|
|
|
|
state.Put("instance_id", instance.Id)
|
2019-03-26 08:29:15 -04:00
|
|
|
|
|
|
|
if s.Debug {
|
2019-04-04 09:17:51 -04:00
|
|
|
ui.Message(fmt.Sprintf("Instance ID %s started. Current instance status %s", instance.Id, instance.Status))
|
2019-04-09 10:46:41 -04:00
|
|
|
ui.Message(fmt.Sprintf("Disk ID %s. ", instance.BootDisk.DiskId))
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
|
2020-07-08 18:46:05 -04:00
|
|
|
// provision generated_data from declared in Builder.Prepare func
|
|
|
|
// see doc https://www.packer.io/docs/extending/custom-builders#build-variables for details
|
|
|
|
s.GeneratedData.Put("SourceImageID", sourceImage.ID)
|
|
|
|
s.GeneratedData.Put("SourceImageName", sourceImage.Name)
|
|
|
|
s.GeneratedData.Put("SourceImageDescription", sourceImage.Description)
|
|
|
|
s.GeneratedData.Put("SourceImageFamily", sourceImage.Family)
|
|
|
|
s.GeneratedData.Put("SourceImageFolderID", sourceImage.FolderID)
|
|
|
|
|
2019-03-26 08:29:15 -04:00
|
|
|
return multistep.ActionContinue
|
|
|
|
}
|
|
|
|
|
2020-04-26 19:19:08 -04:00
|
|
|
func (s *StepCreateInstance) Cleanup(state multistep.StateBag) {
|
2019-04-09 10:46:41 -04:00
|
|
|
config := state.Get("config").(*Config)
|
|
|
|
driver := state.Get("driver").(Driver)
|
2019-03-26 08:29:15 -04:00
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), config.StateTimeout)
|
|
|
|
defer cancel()
|
|
|
|
|
2019-03-26 08:29:15 -04:00
|
|
|
if s.SerialLogFile != "" {
|
|
|
|
ui.Say("Current state 'cancelled' or 'halted'...")
|
2019-04-09 10:46:41 -04:00
|
|
|
err := s.writeSerialLogFile(ctx, state)
|
2019-03-26 08:29:15 -04:00
|
|
|
if err != nil {
|
|
|
|
ui.Error(err.Error())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
instanceIDRaw, ok := state.GetOk("instance_id")
|
|
|
|
if ok {
|
|
|
|
instanceID := instanceIDRaw.(string)
|
|
|
|
if instanceID != "" {
|
|
|
|
ui.Say("Destroying instance...")
|
|
|
|
err := driver.DeleteInstance(ctx, instanceID)
|
|
|
|
if err != nil {
|
|
|
|
ui.Error(fmt.Sprintf(
|
|
|
|
"Error destroying instance (id: %s). Please destroy it manually: %s", instanceID, err))
|
|
|
|
}
|
|
|
|
ui.Message("Instance has been destroyed!")
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
2019-04-04 09:17:51 -04:00
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
subnetIDRaw, ok := state.GetOk("subnet_id")
|
|
|
|
if ok {
|
|
|
|
subnetID := subnetIDRaw.(string)
|
|
|
|
if subnetID != "" {
|
|
|
|
// Destroy the subnet we just created
|
|
|
|
ui.Say("Destroying subnet...")
|
|
|
|
err := driver.DeleteSubnet(ctx, subnetID)
|
|
|
|
if err != nil {
|
|
|
|
ui.Error(fmt.Sprintf(
|
|
|
|
"Error destroying subnet (id: %s). Please destroy it manually: %s", subnetID, err))
|
|
|
|
}
|
|
|
|
ui.Message("Subnet has been deleted!")
|
|
|
|
}
|
2019-04-04 09:17:51 -04:00
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
// Destroy the network we just created
|
|
|
|
networkIDRaw, ok := state.GetOk("network_id")
|
|
|
|
if ok {
|
|
|
|
networkID := networkIDRaw.(string)
|
|
|
|
if networkID != "" {
|
|
|
|
// Destroy the network we just created
|
|
|
|
ui.Say("Destroying network...")
|
|
|
|
err := driver.DeleteNetwork(ctx, networkID)
|
|
|
|
if err != nil {
|
|
|
|
ui.Error(fmt.Sprintf(
|
|
|
|
"Error destroying network (id: %s). Please destroy it manually: %s", networkID, err))
|
|
|
|
}
|
|
|
|
ui.Message("Network has been deleted!")
|
|
|
|
}
|
2019-04-04 09:17:51 -04:00
|
|
|
}
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
diskIDRaw, ok := state.GetOk("disk_id")
|
|
|
|
if ok {
|
|
|
|
ui.Say("Destroying boot disk...")
|
|
|
|
diskID := diskIDRaw.(string)
|
|
|
|
err := driver.DeleteDisk(ctx, diskID)
|
|
|
|
if err != nil {
|
|
|
|
ui.Error(fmt.Sprintf(
|
|
|
|
"Error destroying boot disk (id: %s). Please destroy it manually: %s", diskID, err))
|
|
|
|
}
|
|
|
|
ui.Message("Disk has been deleted!")
|
2019-04-04 09:17:51 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-04-26 19:19:08 -04:00
|
|
|
func (s *StepCreateInstance) writeSerialLogFile(ctx context.Context, state multistep.StateBag) error {
|
2019-03-26 08:29:15 -04:00
|
|
|
sdk := state.Get("sdk").(*ycsdk.SDK)
|
|
|
|
ui := state.Get("ui").(packer.Ui)
|
|
|
|
|
2019-04-09 10:46:41 -04:00
|
|
|
instanceID := state.Get("instance_id").(string)
|
|
|
|
ui.Say("Try get instance's serial port output and write to file " + s.SerialLogFile)
|
|
|
|
serialOutput, err := sdk.Compute().Instance().GetSerialPortOutput(ctx, &compute.GetInstanceSerialPortOutputRequest{
|
|
|
|
InstanceId: instanceID,
|
2019-03-26 08:29:15 -04:00
|
|
|
})
|
|
|
|
if err != nil {
|
2019-04-09 10:46:41 -04:00
|
|
|
return fmt.Errorf("Failed to get serial port output for instance (id: %s): %s", instanceID, err)
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|
|
|
|
if err := ioutil.WriteFile(s.SerialLogFile, []byte(serialOutput.Contents), 0600); err != nil {
|
|
|
|
return fmt.Errorf("Failed to write serial port output to file: %s", err)
|
|
|
|
}
|
|
|
|
ui.Message("Serial port output has been successfully written")
|
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2019-06-06 09:41:58 -04:00
|
|
|
func (c *Config) createInstanceMetadata(sshPublicKey string) (map[string]string, error) {
|
2019-03-26 08:29:15 -04:00
|
|
|
instanceMetadata := make(map[string]string)
|
|
|
|
|
|
|
|
// Copy metadata from config.
|
2019-06-06 09:41:58 -04:00
|
|
|
for k, file := range c.MetadataFromFile {
|
|
|
|
contents, err := ioutil.ReadFile(file)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("error while read file '%s' with content for value of metadata key '%s': %s", file, k, err)
|
|
|
|
}
|
|
|
|
instanceMetadata[k] = string(contents)
|
|
|
|
}
|
|
|
|
|
2019-03-26 08:29:15 -04:00
|
|
|
for k, v := range c.Metadata {
|
|
|
|
instanceMetadata[k] = v
|
|
|
|
}
|
|
|
|
|
|
|
|
if sshPublicKey != "" {
|
|
|
|
sshMetaKey := "ssh-keys"
|
|
|
|
sshKeys := fmt.Sprintf("%s:%s", c.Communicator.SSHUsername, sshPublicKey)
|
|
|
|
if confSSHKeys, exists := instanceMetadata[sshMetaKey]; exists {
|
|
|
|
sshKeys = fmt.Sprintf("%s\n%s", sshKeys, confSSHKeys)
|
|
|
|
}
|
|
|
|
instanceMetadata[sshMetaKey] = sshKeys
|
|
|
|
}
|
|
|
|
|
2019-06-06 09:41:58 -04:00
|
|
|
return instanceMetadata, nil
|
2019-03-26 08:29:15 -04:00
|
|
|
}
|