diff --git a/builder/profitbricks/artefact.go b/builder/profitbricks/artefact.go index d8226d8ea..f277c4f0a 100644 --- a/builder/profitbricks/artefact.go +++ b/builder/profitbricks/artefact.go @@ -4,9 +4,7 @@ import ( "fmt" ) -// dummy Artifact implementation - does nothing type Artifact struct { - // The name of the snapshot snapshotData string } diff --git a/builder/profitbricks/builder.go b/builder/profitbricks/builder.go index 3c6d0cf3e..799b5650e 100644 --- a/builder/profitbricks/builder.go +++ b/builder/profitbricks/builder.go @@ -43,7 +43,6 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe new(stepTakeSnapshot), } - // Setup the state bag and initial state for the steps state := new(multistep.BasicStateBag) state.Put("config", b.config) @@ -61,12 +60,10 @@ func (b *Builder) Run(ui packer.Ui, hook packer.Hook, cache packer.Cache) (packe b.runner.Run(state) - // If there was an error, return that if rawErr, ok := state.GetOk("error"); ok { return nil, rawErr.(error) } - // No errors, must've worked artifact := &Artifact{ snapshotData: state.Get("snapshotname").(string), } diff --git a/builder/profitbricks/builder_test.go b/builder/profitbricks/builder_test.go index dfe134950..7c770bccd 100644 --- a/builder/profitbricks/builder_test.go +++ b/builder/profitbricks/builder_test.go @@ -46,7 +46,6 @@ func TestBuilderPrepare_InvalidKey(t *testing.T) { var b Builder config := testConfig() - // Add a random key config["i_should_not_be_valid"] = true warnings, err := b.Prepare(config) if len(warnings) > 0 { @@ -61,7 +60,6 @@ func TestBuilderPrepare_Servername(t *testing.T) { var b Builder config := testConfig() - // Test default delete(config, "servername") warnings, err := b.Prepare(config) if len(warnings) > 0 { @@ -73,7 +71,6 @@ func TestBuilderPrepare_Servername(t *testing.T) { expected := "packer" - // Test set config["servername"] = expected b = Builder{} warnings, err = b.Prepare(config) diff --git a/builder/profitbricks/config.go b/builder/profitbricks/config.go index 3df25fe57..eb312d174 100644 --- a/builder/profitbricks/config.go +++ b/builder/profitbricks/config.go @@ -99,14 +99,13 @@ func NewConfig(raws ...interface{}) (*Config, []string, error) { c.Comm.SSHPort = 22 if c.PBUsername == "" { - // Required configurations that will display errors if not set errs = packer.MultiErrorAppend( errs, errors.New("ProfitBricks username is required")) } if c.PBPassword == "" { errs = packer.MultiErrorAppend( - errs, errors.New("Profitbricks passwrod is required")) + errs, errors.New("ProfitBricks password is required")) } if c.ServerName == "" { diff --git a/builder/profitbricks/step_create_server.go b/builder/profitbricks/step_create_server.go index 81ff62554..a30ac5f79 100644 --- a/builder/profitbricks/step_create_server.go +++ b/builder/profitbricks/step_create_server.go @@ -24,7 +24,6 @@ func (s *stepCreateServer) Run(state multistep.StateBag) multistep.StepAction { ui.Say("Creating Virutal datacenter...") - //Create a Virtual datacenter datacenter := profitbricks.CreateDatacenter(profitbricks.CreateDatacenterRequest{ DCProperties: profitbricks.DCProperties{ Name: c.ServerName, diff --git a/builder/profitbricks/step_create_ssh_key.go b/builder/profitbricks/step_create_ssh_key.go index 6d258cc0c..a11f49bae 100644 --- a/builder/profitbricks/step_create_ssh_key.go +++ b/builder/profitbricks/step_create_ssh_key.go @@ -13,13 +13,11 @@ import ( "golang.org/x/crypto/ssh" ) -// StepCreateSSHKey represents a Packer build step that generates SSH key pairs. type StepCreateSSHKey struct { Debug bool DebugKeyPath string } -// Run executes the Packer build step that generates SSH key pairs. func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { ui := state.Get("ui").(packer.Ui) @@ -45,7 +43,6 @@ func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { ui.Error(err.Error()) return multistep.ActionHalt } - //fmt.Println("PUTTING") state.Put("privateKey", string(pem.EncodeToMemory(&priv_blk))) state.Put("publicKey", string(ssh.MarshalAuthorizedKey(pub))) @@ -57,7 +54,6 @@ func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionHalt } - // Write out the key err = pem.Encode(f, &priv_blk) f.Close() if err != nil { @@ -68,5 +64,4 @@ func (s *StepCreateSSHKey) Run(state multistep.StateBag) multistep.StepAction { return multistep.ActionContinue } -// Nothing to clean up. SSH keys are associated with a single GCE instance. func (s *StepCreateSSHKey) Cleanup(state multistep.StateBag) {} diff --git a/website/source/docs/builders/profitbricks.html.md b/website/source/docs/builders/profitbricks.html.md new file mode 100644 index 000000000..7482ef331 --- /dev/null +++ b/website/source/docs/builders/profitbricks.html.md @@ -0,0 +1,79 @@ +--- +description: | + The `profitbricks` Packer builder is able to create new images for use with + ProfitBricks. The builder takes a source image, runs any provisioning necessary + on the image after launching it, then snapshots it into a reusable image. This + reusable image can then be used as the foundation of new servers that are + launched within ProfitBricks. +layout: docs +page_title: ProfitBricks Builder +... + +# ProfitBricks Builder + +Type: `profitbricks` + +The `profitbricks` Packer builder is able to create new images for use with +[ProfitBricks](https://www.profitbricks.com). The builder takes a source image, +runs any provisioning necessary on the image after launching it, then snapshots +it into a reusable image. This reusable image can then be used as the foundation +of new servers that are launched within ProfitBricks. + +The builder does *not* manage images. Once it creates an image, it is up to you +to use it or delete it. + +## Configuration Reference + +There are many configuration options available for the builder. They are +segmented below into two categories: required and optional parameters. Within +each category, the available configuration keys are alphabetized. + +In addition to the options listed here, a +[communicator](/docs/templates/communicator.html) can be configured for this +builder. + +### Required: + +- `pbpasswrod` (string) - ProfitBricks password. It + can also be specified via environment variable `PROFITBRICKS_PASSWORD`, + if set. + +- `pbusername` (string) - ProfitBricks username. It + can also be specified via environment variable `PROFITBRICKS_USERNAME`, + if set. + +- `servername` (string) - The name of the server that will be created. + +### Optional: + +- `cores` (int) - Number of server cores default value 4. + +- `disksize` (string) - Desired disk size default value 50gb + +- `disktype` (string) - Desired disk type default value "HDD" + +- `image` (string) - ProfitBricks volume image default value `Ubuntu-16.04` + +- `pburl` (string) - ProfitBricks REST Url. + +- `ram` (int) - RAM size for the server default value 2048. + +- `region` (string) - ProfitBricks region default value "us/las". + +## Basic Example + +Here is a basic example. It is completely valid as soon as you enter your own +access tokens: + +``` {.javascript} +{ + "builders": [ + { + "type": "profitbricks", + "image": "Ubuntu-16.04", + "pbusername": "pb_username", + "pbpassword": "pb_password", + "servername": "packer" + } +} +```