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

Allow to specify user_data in a template #267

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions builder/powervs/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func (b *Builder) Run(ctx context.Context, ui packer.Ui, hook packer.Hook) (pack
&StepCreateInstance{
InstanceName: b.config.InstanceName,
KeyPairName: b.config.KeyPairName,
UserData: b.config.UserData,
},
&communicator.StepConnect{
Config: &b.config.RunConfig.Comm,
Expand Down
2 changes: 2 additions & 0 deletions builder/powervs/builder.hcl2spec.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions builder/powervs/common/run_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type RunConfig struct {
InstanceName string `mapstructure:"instance_name" required:"true"`
KeyPairName string `mapstructure:"key_pair_name" required:"true"`
SubnetIDs []string `mapstructure:"subnet_ids" required:"false"`
UserData string `mapstructure:"user_data" required:"false"`
DHCPNetwork bool `mapstructure:"dhcp_network" required:"false"`
Source Source `mapstructure:"source" required:"true"`
Capture Capture `mapstructure:"capture" required:"true"`
Expand Down
3 changes: 3 additions & 0 deletions builder/powervs/step_create_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package powervs

import (
"context"
b64 "encoding/base64"
"fmt"
"time"

Expand All @@ -15,6 +16,7 @@ import (
type StepCreateInstance struct {
InstanceName string
KeyPairName string
UserData string

doCleanup bool
}
Expand Down Expand Up @@ -54,6 +56,7 @@ func (s *StepCreateInstance) Run(_ context.Context, state multistep.StateBag) mu
Processors: core.Float64Ptr(0.5),
ServerName: &s.InstanceName,
StorageType: *imageRef.StorageType,
UserData: b64.StdEncoding.EncodeToString([]byte(s.UserData)),
}
ui.Message("Creating Instance")
ins, err := instanceClient.Create(body)
Expand Down
Loading