Giter Club home page Giter Club logo

packer-plugin-digitalocean's Introduction

Packer Plugin DigitalOcean

The Digitalocean multi-component plugin can be used with HashiCorp Packer to create custom images. For the full list of available features for this plugin see docs.

Installation

Using pre-built releases

Using the packer init command

Starting from version 1.7, Packer supports a new packer init command allowing automatic installation of Packer plugins. Read the Packer documentation for more information.

To install this plugin, copy and paste this code into your Packer configuration . Then, run packer init.

packer {
  required_plugins {
    digitalocean = {
      version = ">= 1.0.4"
      source  = "github.com/digitalocean/digitalocean"
    }
  }
}

Manual installation

You can find pre-built binary releases of the plugin here. Once you have downloaded the latest archive corresponding to your target OS, uncompress it to retrieve the plugin binary file corresponding to your platform. To install the plugin, please follow the Packer documentation on installing a plugin.

From Sources

If you prefer to build the plugin from sources, clone the GitHub repository locally and run the command go build from the root directory. Upon successful compilation, a packer-plugin-digitalocean plugin binary file can be found in the root directory. To install the compiled plugin, please follow the official Packer documentation on installing a plugin.

Configuration

For more information on how to configure the plugin, please read the documentation located in the docs/ directory.

Contributing

  • If you think you've found a bug in the code or you have a question regarding the usage of this software, please reach out to us by opening an issue in this GitHub repository.
  • Contributions to this project are welcome: if you want to add a feature or a fix a bug, please do so by opening a Pull Request in this GitHub repository. In case of feature contribution, we kindly ask you to open an issue to discuss it beforehand.

packer-plugin-digitalocean's People

Contributors

alrs avatar andrewsomething avatar azr avatar bryan-lester-dolby avatar cbednarski avatar dependabot[bot] avatar hbdgr avatar jengoldstrich avatar jescalan avatar lbajolet-hashicorp avatar lfarnell avatar lisimia avatar markpeek avatar miry avatar mitchellh avatar mmckeen avatar mwhooker avatar mzupan avatar nywilken avatar orivej avatar pearkes avatar pragnesh avatar rasa avatar rickard-von-essen avatar rizkybiz avatar swampdragons avatar sylviamoss avatar ufukty avatar viktorbenei avatar vtolstov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

packer-plugin-digitalocean's Issues

Release 1.1.0 is broken

Overview of the Issue

The release workflow for version 1.1.0 failed, causing packer init to fail when trying to use the latest version (automatically with a version constraint such as ~> 1.0 or using the specific version)

Reproduction Steps

Create a versions file with just the DO plugin:

# versions.pkr.hcl

packer {
  required_plugins {
    digitalocean = {
      version = "~> 1.0",
      source  = "github.com/digitalocean/digitalocean"
    }
  }
}
$ packer init .
Failed getting the "github.com/digitalocean/digitalocean" plugin:
2 errors occurred:
	* could not parse release version list. Malformed version: list
	* could not get sha256 checksum file for github.com/digitalocean/digitalocean version 1.1.0. Is the file present on the release and correctly named ? GET https://github.com/digitalocean/packer-plugin-digitalocean/releases/download/v1.1.0/packer-plugin-digitalocean_v1.1.0_SHA256SUMS: 404  []

Plugin and Packer version

$ packer version
Packer v1.8.3

Log Fragments and crash.log files

The release workflow failed: https://github.com/digitalocean/packer-plugin-digitalocean/runs/8236600596?check_suite_focus=true

packer-provisioner-ansible: Failed to transfer file

I found this error but it doesn't seem to be a communication error! But the debug does not provide more data about the transfer

Packer version: 1.8.5
ansible [core 2.14.1]

`
2023/02/02 18:13:19 packer-provisioner-ansible plugin: [INFO] 0 bytes written for 'stdout'
2023/02/02 18:13:19 packer-provisioner-ansible plugin: [INFO] 0 bytes written for 'stderr'
2023/02/02 18:13:19 packer-provisioner-ansible plugin: [INFO] RPC client: Communicator ended with: 0
2023/02/02 18:13:19 packer-provisioner-ansible plugin: [INFO] 0 bytes written for 'stdin'
digitalocean.autogenerated_1: fatal: [default]: FAILED! => {"msg": "failed to transfer file to /home/faioli/.ansible/tmp/ansible-local-1283144fbgpucvw/tmp6vc_x27k /root/.ansible/tmp/ansible-tmp-1675372395.6370904-1283148-186012402299502/AnsiballZ_setup.py:\n\n"}
digitalocean.autogenerated_1:
digitalocean.autogenerated_1: PLAY RECAP *********************************************************************
digitalocean.autogenerated_1: default : ok=0 changed=0 unreachable=0 failed=1 skipped=0 rescued=0 ignored=0
digitalocean.autogenerated_1:
2023/02/02 18:13:19 packer-provisioner-ansible plugin: shutting down the SSH proxy
2023/02/02 18:13:19 [INFO] (telemetry) ending ansible
==> digitalocean.autogenerated_1: Provisioning step had errors: Running the cleanup provisioner, if present...
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'StepConnect'. Press enter to continue.
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'stepDropletInfo'. Press enter to continue.
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'stepCreateDroplet'. Press enter to continue.
==> digitalocean.autogenerated_1: Destroying droplet...
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'stepCreateSSHKey'. Press enter to continue.
==> digitalocean.autogenerated_1: Deleting temporary ssh key...
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'StepDumpSSHKey'. Press enter to continue.
==> digitalocean.autogenerated_1: Pausing before cleanup of step 'StepSSHKeyGen'. Press enter to continue.
2023/02/02 18:16:30 [INFO] (telemetry) ending digitalocean.autogenerated_1
2023/02/02 18:16:30 Waiting on builds to complete...
==> Wait completed after 5 minutes 54 seconds
2023/02/02 18:16:30 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2023/02/02 18:16:30 machine readable: digitalocean.autogenerated_1,error []string{"Error executing Ansible: Non-zero exit status: exit status 2"}
==> Builds finished but no artifacts were created.
2023/02/02 18:16:30 [INFO] (telemetry) Finalizing.
Build 'digitalocean.autogenerated_1' errored after 5 minutes 54 seconds: Error executing Ansible: Non-zero exit status: exit status 2

==> Wait completed after 5 minutes 54 seconds

==> Some builds didn't complete successfully and had errors:
--> digitalocean.autogenerated_1: Error executing Ansible: Non-zero exit status: exit status 2
`

Initiate all transfers before blocking on completion

Currently, when we distribute images to all regions, we do so one at a time. After each transfer is initiated, we wait until it is completed to start the next one. These transfers can happen in parallel. This would have a few benefits. Large images transferred to many regions may take quite awhile to complete. Currently, if we timeout, the build may fail before initiating all transfers. Also, if a single transfer errors, the others are never initiated.

Surfaced from this related issue: #122 (comment)

Specifiying an SSH private key causes the builder to crash.

Overview of the Issue

The digitalocean builder crashes during droplet creation when ssh_private_key_file is specified.

I originally filed a version of this bug against the main packer repo before I debugged it further: hashicorp/packer#11118

Reproduction Steps

Packer version

1.7.3, digitalocean plugin 1.0.0

Simplified Packer Buildfile

Sources
variable "digital_ocean_api_key" {
  type = string
}

source "digitalocean" "default" {
  api_token     = var.digital_ocean_api_key
  region        = "tor1"
  size          = "2gb"
}
Buildfile
variable "deploy_private_key_file" {
  type = string
  default = null
}

variable "digital_ocean_application_image_id" {
  type = string
  default = null
}

variable "commit_sha" {
  type = string
  default = null
}

variable "branch" {
  type = string
  default = null
}

build {
  name = "application_server"
  source "source.digitalocean.default" {
    ssh_username = "deploy"
    ssh_private_key_file = var.deploy_private_key_file
    image = var.digital_ocean_application_image_id
    snapshot_name = "server-${var.branch}_${var.commit_sha}"
    snapshot_regions = ["tor1", "nyc3"]
  }

  provisioner "ansible" {
    extra_arguments = ["--extra-vars", "commit_sha=${var.commit_sha}"]
    playbook_file   = "ansible_playbooks/application_server.yml"
  }
}

Operating system and Environment details

I see this error on Github Actions runners, full specs here: https://github.com/actions/virtual-environments/blob/ubuntu20/20210621.1/images/linux/Ubuntu2004-README.md

I also see the error on my local machine, which is a Mac running macOS 11.4

Log Fragments and crash.log files

Packer output
application_server.digitalocean.default: output will be in this color.

==> application_server.digitalocean.default: Using existing SSH private key
==> application_server.digitalocean.default: No public SSH key found; skipping SSH public key import...
Build 'application_server.digitalocean.default' errored after 504 milliseconds 241 microseconds: unexpected EOF

==> Wait completed after 504 milliseconds 294 microseconds

==> Some builds didn't complete successfully and had errors:
--> application_server.digitalocean.default: unexpected EOF

==> Builds finished but no artifacts were created.
panic: interface conversion: interface {} is nil, not int
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 
2021/06/24 18:28:36 packer-builder-digitalocean plugin: goroutine 79 [running]:
2021/06/24 18:28:36 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-digitalocean/builder/digitalocean.(*stepCreateDroplet).Run(0xc0003a07e8, 0x5e4ce20, 0xc000af5540, 0x5e4d868, 0xc0009b10b0, 0x0)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/builder/digitalocean/step_create_droplet.go:24 +0x886
2021/06/24 18:28:36 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc0009b1140, 0x5e4ce20, 0xc000af5540, 0x5e4d868, 0xc0009b10b0)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/multistep/basic_runner.go:70 +0x234
2021/06/24 18:28:36 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-digitalocean/builder/digitalocean.(*Builder).Run(0xc00045a900, 0x5e4ce20, 0xc000af5540, 0x5e66138, 0xc000ec3710, 0x5dbd780, 0xc000d16160, 0xc00085fd70, 0x4ab6740, 0xc0000cffc0, ...)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/builder/digitalocean/builder.go:116 +0x7f4
2021/06/24 18:28:36 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0xc000720280, 0x1, 0xc00002ef9c, 0x0, 0x0)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/rpc/builder.go:117 +0x1c4
2021/06/24 18:28:36 packer-builder-digitalocean plugin: reflect.Value.call(0xc000cd36e0, 0xc00000e5e0, 0x13, 0x56cc20d, 0x4, 0xc00071bf08, 0x3, 0x3, 0xc000ec6180, 0x0, ...)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/usr/local/go/src/reflect/value.go:476 +0x8e7
2021/06/24 18:28:36 packer-builder-digitalocean plugin: reflect.Value.Call(0xc000cd36e0, 0xc00000e5e0, 0x13, 0xc0006a7f08, 0x3, 0x3, 0x708fe5, 0xc0006a7f48, 0xc0006a7f2c)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/usr/local/go/src/reflect/value.go:337 +0xb9
2021/06/24 18:28:36 packer-builder-digitalocean plugin: net/rpc.(*service).call(0xc0007202c0, 0xc0000ec5f0, 0xc000dc01b8, 0xc000dc01c0, 0xc000d62600, 0xc000d176c0, 0x469d880, 0xc00002ef98, 0x18a, 0x4577e60, ...)
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/usr/local/go/src/net/rpc/server.go:377 +0x189
2021/06/24 18:28:36 packer-builder-digitalocean plugin: created by net/rpc.(*Server).ServeCodec
2021/06/24 18:28:36 packer-builder-digitalocean plugin: 	/usr/local/go/src/net/rpc/server.go:474 +0x44d
2021/06/24 18:28:36 [INFO] (telemetry) ending 
2021/06/24 18:28:36 ui error: Build 'application_server.digitalocean.default' errored after 504 milliseconds 241 microseconds: unexpected EOF
2021/06/24 18:28:36 ui: 
==> Wait completed after 504 milliseconds 294 microseconds
2021/06/24 18:28:36 machine readable: error-count []string{"1"}
2021/06/24 18:28:36 ui error: 
==> Some builds didn't complete successfully and had errors:
2021/06/24 18:28:36 /usr/local/bin/packer: plugin process exited
2021/06/24 18:28:36 machine readable: application_server.digitalocean.default,error []string{"unexpected EOF"}
2021/06/24 18:28:36 ui error: --> application_server.digitalocean.default: unexpected EOF
2021/06/24 18:28:36 ui: 
==> Builds finished but no artifacts were created.
2021/06/24 18:28:36 [INFO] (telemetry) Finalizing.
2021/06/24 18:28:37 waiting for all plugin processes to complete...
2021/06/24 18:28:37 /usr/local/bin/packer: plugin process exited



!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Packer crashed! This is always indicative of a bug within Packer.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Packer[1] so that we can fix this.

[1]: https://github.com/hashicorp/packer/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! PACKER CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Digital Ocean docs page seems outdated compared to the code in docs repo

Overview of the Issue

Actual site content seems outdated / out of sync compared to the code in this repo. For example, https://www.packer.io/docs/builders/digitalocean#required section shows that droplet sizes can be checked at https://developers.digitalocean.com/documentation/v2/#list-all-sizes but the correct updated URL for that is https://docs.digitalocean.com/reference/api/api-reference/#operation/list_all_sizes which is correctly used in https://github.com/hashicorp/packer-plugin-digitalocean/blob/main/docs-partials/builder/digitalocean/Config-required.mdx code of the docs. So the docs web page seems outdated

Reproduction Steps

Check https://www.packer.io/docs/builders/digitalocean#required and compare it with https://github.com/hashicorp/packer-plugin-digitalocean/blob/main/docs-partials/builder/digitalocean/Config-required.mdx content

Problem copying snapshots to regions when building

Overview of the Issue

Since yesterday, packer build has bailed out when copying an image to other regions like so:

2024/02/06 08:30:14 packer-plugin-digitalocean_v1.1.1_x5.0_linux_amd64 plugin: 2024/02/06 08:30:14 Looking up snapshot ID for snapshot: test
2024/02/06 08:30:16 ui: ==> digitalocean: transferring Snapshot ID: 2030587156
2024/02/06 08:30:16 packer-plugin-digitalocean_v1.1.1_x5.0_linux_amd64 plugin: 2024/02/06 08:30:16 Waiting for up to 1200 seconds for image transfer to become completed
2024/02/06 08:30:16 packer-plugin-digitalocean_v1.1.1_x5.0_linux_amd64 plugin: 2024/02/06 08:30:16 Checking action status... (attempt: 1)
2024/02/06 08:30:16 ui error: ==> digitalocean: Error waiting for snapshot transfer: GET https://api.digitalocean.com/v2/images/2030587156/actions/2030585883: 404 (request "b3086244-9084-4591-bb59-0d3c9164c9a1") The resource you were accessing could not be found.

What's interesting here is 2030587156 is not a valid image id. That's an action id! And it's easy to see where this value came from:

https://github.com/digitalocean/packer-plugin-digitalocean/blob/main/builder/digitalocean/step_snapshot.go#L98

Breaking down what's happening:

			imageTransfer, _, err := client.ImageActions.Transfer(context.TODO(), images[0].ID, transferRequest)
			if err != nil {
				err := fmt.Errorf("Error transferring snapshot: %s", err)
				state.Put("error", err)
				ui.Error(err.Error())
				return multistep.ActionHalt
			}
			ui.Say(fmt.Sprintf("transferring Snapshot ID: %d", imageTransfer.ID))
			if err := WaitForImageState(godo.ActionCompleted, imageTransfer.ID, action.ID,
				client, 20*time.Minute); err != nil {
				// If we get an error the first time, actually report it
				err := fmt.Errorf("Error waiting for snapshot transfer: %s", err)
				state.Put("error", err)
				ui.Error(err.Error())
				return multistep.ActionHalt
			}

Below we create a transfer request. This uses images[0].ID so posts to /images/1234/actions {type:transfer, region:...}

		imageTransfer, _, err := client.ImageActions.Transfer(context.TODO(), images[0].ID, transferRequest)

And then we're suppose to poll that action to wait for it to finish. Polling that would be /images/1234/actions/imageTransfer.ID.

But instead, we're passing what seem to me the wrong things to WaitForImageState:

		if err := WaitForImageState(godo.ActionCompleted, imageTransfer.ID, action.ID,

We're passing in the imageTransfer.ID (which is an action id!) to images/<...>/, and then we're passing in action.ID which comes from much higher:

	action, _, err := client.DropletActions.Snapshot(context.TODO(), dropletId, c.SnapshotName)

... so that's the ID of a snapshot action on a droplet. This feels like a bug, and I'm not sure how this ever worked. Shouldn't the code be:

			imageTransfer, _, err := client.ImageActions.Transfer(context.TODO(), images[0].ID, transferRequest)
			if err != nil {
				err := fmt.Errorf("Error transferring snapshot: %s", err)
				state.Put("error", err)
				ui.Error(err.Error())
				return multistep.ActionHalt
			}
			ui.Say(fmt.Sprintf("transferring Snapshot ID: %d", imageTransfer.ID))
-			if err := WaitForImageState(godo.ActionCompleted, imageTransfer.ID, action.ID,
+			if err := WaitForImageState(godo.ActionCompleted, images[0].ID, imageTransfer.ID,
				client, 20*time.Minute); err != nil {
				// If we get an error the first time, actually report it
				err := fmt.Errorf("Error waiting for snapshot transfer: %s", err)
				state.Put("error", err)
				ui.Error(err.Error())
				return multistep.ActionHalt
			}

I don't understand how this ever worked to be honest. My two theories are:

  • we were running old versions of things that didn't have this seeming bug
  • digitalocean changed their API? Maybe the "ID" that came back from the transferimage action was the id of the image mistakenly. But that doesn't explain how passing the action.ID would have worked too.... Hmm. Unless DigitalOcean started returning an error for invalid actions when previously they returned okay responses? That would account for it

Reproduction Steps

packer build with a configuration like this:

{
      "type": "digitalocean",
      "droplet_name": "some-droplet",
      "image": "debian-11-x64",
      "region": "sfo3",
      "size": "g-4vcpu-16gb",

      "ssh_username": "root",
      "ssh_timeout": "60m",

      "snapshot_name": "some-snapshot-{{isotime \"20060102\"}}",
      "snapshot_regions": ["sfo3","nyc3","ams3","syd1"],
      "tags": ["sometag"],

      "private_networking": false
}

Plugin and Packer version

Packer v1.9.2
packer-plugin-digitalocean_v1.1.1_x5.0_linux_amd64

Operating system and Environment details

Linux 4.19.0-23-cloud-amd64 #1 SMP Debian 4.19.269-1 (2022-12-20) x86_64 GNU/Linux

packer crash

This issue was originally opened by @kra in hashicorp/packer#11208 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

packer crashed and told me to report it here

Reproduction Steps

packer build -var-file=conf/variables.pkr.hcl -var "image=89824917" deploy/baseinstall_update_template.pkr.hcl

Packer version

Packer v1.7.4

Simplified Packer Buildfile

# Packer template to create update image from baseinstall image

variable "deploy_access_token" {
    type = string
    default = ""
}

variable "image" {
    type = string
}

source "digitalocean" "foo" {
    api_token    = "${var.deploy_access_token}"
    droplet_name = "futel-stage.phu73l.net"
    image        = "${var.image}"
    region       = "sfo1"
    size         = "s-1vcpu-1gb"
    communicator = "ssh"
    ssh_username = "futel"
    ssh_port = "42422"
    ssh_private_key_file = "conf/id_rsa"
    snapshot_name = "update"
}

build {
    sources = ["source.digitalocean.foo"]
    provisioner "ansible" {
        groups = ["baseinstall"]
            use_proxy = "false"
            playbook_file = "deploy/update_asterisk_playbook.yml"
            extra_arguments = ["--vault-password-file=conf/vault_pass_generic.txt"]        
        }
}

Operating system and Environment details

ubuntu

Log Fragments and crash.log files

2021/08/14 16:49:42 [INFO] Packer version: 1.7.4 [go1.16.6 linux amd64]
2021/08/14 16:49:42 [TRACE] discovering plugins in /usr/bin
2021/08/14 16:49:42 [TRACE] discovering plugins in /home/karl/.packer.d/plugins
2021/08/14 16:49:42 [TRACE] discovering plugins in .
2021/08/14 16:49:42 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/08/14 16:49:42 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/karl/.packerconfig
2021/08/14 16:49:42 [WARN] Config file doesn't exist: /home/karl/.packerconfig
2021/08/14 16:49:42 [INFO] Setting cache directory: /home/karl/Documents/futel-installation/asteriskserver/packer_cache
2021/08/14 16:49:42 [TRACE] validateValue: not active for deploy_access_token, so skipping
2021/08/14 16:49:42 [TRACE] validateValue: not active for image, so skipping
2021/08/14 16:49:42 [TRACE] Starting internal plugin packer-builder-digitalocean
2021/08/14 16:49:42 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-builder-digitalocean"}
2021/08/14 16:49:42 Waiting for RPC address for: /usr/bin/packer
2021/08/14 16:49:42 packer-builder-digitalocean plugin: [INFO] Packer version: 1.7.4 [go1.16.6 linux amd64]
2021/08/14 16:49:42 packer-builder-digitalocean plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/08/14 16:49:42 packer-builder-digitalocean plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/karl/.packerconfig
2021/08/14 16:49:42 packer-builder-digitalocean plugin: [WARN] Config file doesn't exist: /home/karl/.packerconfig
2021/08/14 16:49:42 packer-builder-digitalocean plugin: [INFO] Setting cache directory: /home/karl/Documents/futel-installation/asteriskserver/packer_cache
2021/08/14 16:49:42 packer-builder-digitalocean plugin: args: []string{"packer-builder-digitalocean"}
2021/08/14 16:49:42 packer-builder-digitalocean plugin: Plugin address: unix /tmp/packer-plugin251786442
2021/08/14 16:49:42 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin251786442
2021/08/14 16:49:42 packer-builder-digitalocean plugin: Waiting for connection...
2021/08/14 16:49:42 packer-builder-digitalocean plugin: Serving a plugin connection...
2021/08/14 16:49:42 [TRACE] Starting internal plugin packer-provisioner-ansible
2021/08/14 16:49:42 Starting plugin: /usr/bin/packer []string{"/usr/bin/packer", "plugin", "packer-provisioner-ansible"}
2021/08/14 16:49:42 Waiting for RPC address for: /usr/bin/packer
2021/08/14 16:49:42 packer-provisioner-ansible plugin: [INFO] Packer version: 1.7.4 [go1.16.6 linux amd64]
2021/08/14 16:49:42 packer-provisioner-ansible plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2021/08/14 16:49:42 packer-provisioner-ansible plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/karl/.packerconfig
2021/08/14 16:49:42 packer-provisioner-ansible plugin: [WARN] Config file doesn't exist: /home/karl/.packerconfig
2021/08/14 16:49:42 packer-provisioner-ansible plugin: [INFO] Setting cache directory: /home/karl/Documents/futel-installation/asteriskserver/packer_cache
2021/08/14 16:49:42 packer-provisioner-ansible plugin: args: []string{"packer-provisioner-ansible"}
2021/08/14 16:49:42 packer-provisioner-ansible plugin: Plugin address: unix /tmp/packer-plugin941654698
2021/08/14 16:49:42 packer-provisioner-ansible plugin: Waiting for connection...
2021/08/14 16:49:42 Received unix RPC address for /usr/bin/packer: addr is /tmp/packer-plugin941654698
2021/08/14 16:49:42 packer-provisioner-ansible plugin: Serving a plugin connection...
2021/08/14 16:49:43 packer-provisioner-ansible plugin: ansible-playbook version: 2.11.1
2021/08/14 16:49:43 ui: �[1;32mdigitalocean.foo: output will be in this color.�[0m
2021/08/14 16:49:43 ui:
2021/08/14 16:49:43 Build debug mode: false
2021/08/14 16:49:43 Force build: false
2021/08/14 16:49:43 On error:
2021/08/14 16:49:43 Waiting on builds to complete...
2021/08/14 16:49:43 Starting build run: digitalocean.foo
2021/08/14 16:49:43 Running builder:
2021/08/14 16:49:43 [INFO] (telemetry) Starting builder
2021/08/14 16:49:43 ui: �[1;32m==> digitalocean.foo: Using existing SSH private key�[0m
2021/08/14 16:49:43 ui: �[1;32m==> digitalocean.foo: No public SSH key found; skipping SSH public key import...�[0m
2021/08/14 16:49:43 packer-builder-digitalocean plugin: panic: interface conversion: interface {} is nil, not int
2021/08/14 16:49:43 packer-builder-digitalocean plugin:
2021/08/14 16:49:43 packer-builder-digitalocean plugin: goroutine 86 [running]:
2021/08/14 16:49:43 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-digitalocean/builder/digitalocean.(*stepCreateDroplet).Run(0xc00033e8d8, 0x5e4ce80, 0xc0004be480, 0x5e4d8c8, 0xc000a3f560, 0x0)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/builder/digitalocean/step_create_droplet.go:24 +0x886
2021/08/14 16:49:43 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-sdk/multistep.(*BasicRunner).Run(0xc000a3f5f0, 0x5e4ce80, 0xc0004be480, 0x5e4d8c8, 0xc000a3f560)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/multistep/basic_runner.go:70 +0x234
2021/08/14 16:49:43 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-digitalocean/builder/digitalocean.(*Builder).Run(0xc000177b00, 0x5e4ce80, 0xc0004be480, 0x5e66198, 0xc000a3f4d0, 0x5dbd7e0, 0xc0000436a0, 0xc000a3f380, 0x4ab6740, 0xc000043680, ...)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/builder/digitalocean/builder.go:116 +0x7f4
2021/08/14 16:49:43 packer-builder-digitalocean plugin: github.com/hashicorp/packer-plugin-sdk/rpc.(*BuilderServer).Run(0xc00004a040, 0x1, 0xc00033e85c, 0x0, 0x0)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /home/circleci/go/pkg/mod/github.com/hashicorp/[email protected]/rpc/builder.go:117 +0x1c4
2021/08/14 16:49:43 packer-builder-digitalocean plugin: reflect.Value.call(0xc0001844e0, 0xc0005b8088, 0x13, 0x56cc20d, 0x4, 0xc00057ef08, 0x3, 0x3, 0x0, 0x0, ...)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /usr/local/go/src/reflect/value.go:476 +0x8e7
2021/08/14 16:49:43 packer-builder-digitalocean plugin: reflect.Value.Call(0xc0001844e0, 0xc0005b8088, 0x13, 0xc000722f08, 0x3, 0x3, 0x0, 0x0, 0x0)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /usr/local/go/src/reflect/value.go:337 +0xb9
2021/08/14 16:49:43 packer-builder-digitalocean plugin: net/rpc.(*service).call(0xc00004a080, 0xc00019c0a0, 0xc000558060, 0xc000558070, 0xc000040300, 0xc0000420a0, 0x469d880, 0xc00033e858, 0x18a, 0x4577e60, ...)
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /usr/local/go/src/net/rpc/server.go:377 +0x189
2021/08/14 16:49:43 packer-builder-digitalocean plugin: created by net/rpc.(*Server).ServeCodec
2021/08/14 16:49:43 packer-builder-digitalocean plugin: /usr/local/go/src/net/rpc/server.go:474 +0x44d
2021/08/14 16:49:43 /usr/bin/packer: plugin process exited
2021/08/14 16:49:43 [INFO] (telemetry) ending
2021/08/14 16:49:43 ui error: �[1;31mBuild 'digitalocean.foo' errored after 8 milliseconds 345 microseconds: unexpected EOF�[0m
2021/08/14 16:49:43 ui:
==> Wait completed after 8 milliseconds 497 microseconds
2021/08/14 16:49:43 machine readable: error-count []string{"1"}
2021/08/14 16:49:43 ui error:
==> Some builds didn't complete successfully and had errors:
2021/08/14 16:49:43 machine readable: digitalocean.foo,error []string{"unexpected EOF"}
2021/08/14 16:49:43 ui error: --> digitalocean.foo: unexpected EOF
2021/08/14 16:49:43 ui:
==> Builds finished but no artifacts were created.
2021/08/14 16:49:43 [INFO] (telemetry) Finalizing.
2021/08/14 16:49:43 waiting for all plugin processes to complete...
2021/08/14 16:49:43 /usr/bin/packer: plugin process exited

Add option to skip snapshot creation

Description

The DigitalOcean builder could have an option to skip the snapshot creation.

Other builders like the AWS and GCP one already implement this, with the skip_create_ami and skip_create_image configuration options respectively.

Use Case(s)

This behavior would be useful in CI/CD environments, where we could test that an image configuration is valid in a pipeline, without actually creating the resource on DigitalOcean. Current alternatives require calling the DigitalOcean API to delete the snapshot after the long-running create snapshot and transfer snapshot steps are done.

Potential configuration

source "digitalocean" "example" {
  api_token            = "YOUR API KEY"
  image                = "ubuntu-22-04-x64"
  region               = "nyc3"
  size                 = "s-1vcpu-1gb"
  ssh_username         = "root"
  # new option
  skip_create_snapshot = true
}

Potential References

AWS and GCP builders do it on the step_create_*.go files, which seem equivalent to the step_snapshot.go in this repository.

Snapshot Tags

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Currently we can tag droplets as they are created by packer. It would also be great to have the resultant image snapshots have tags

Use Case(s)

Tags could then be used to filter snapshots for further management by other tools (for example terraform data digitalocean_images)

Potential configuration

Potential References

https://docs.digitalocean.com/reference/api/api-reference/#operation/tag_resource

Use token env var like the terraform provider for consistency

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

The terraform provider supports DIGITALOCEAN_TOKEN and DIGITALOCEAN_ACCESS_TOKEN environment variables, and the Packer build plugin uses DIGITALOCEAN_API_TOKEN. Would be interesting to have them support the same environment variables for sake of consistency between the two.

Use Case(s)

User or CI/CD can run both tools without having to set yet another environment variable with the same content.

Potential configuration

Potential References

https://github.com/digitalocean/terraform-provider-digitalocean/blob/main/digitalocean/provider.go#L20-L21

`ssh_private_key_file` used for both droplet creation and subsequent connection

Overview of the Issue

Previously I had an issue when providing a private SSH key to connect to my newly created droplet: #19

The fix provided in #20 and shipped with v1.0.1 fixed my issue and I've been using that version ever since.

Now I'm (finally) upgrading to a more recent version and my existing configuration results in a different error.

The private key specified in my config is being used as both the root key when creating the droplet and the ssh key when connecting as a user (which may not be root) to provision the droplet.

In my case, I have a user named deploy that already exists on the base image that I want to connect as. Giving root the same key as deploy is no bueno.

I noticed this because I have that key added to DO already separately, and when trying to create the root key it fails since there's a duplicate.

I believe this bug emerged in the following commit: 0462cbc

Versions of the plugin pre-1.2.0 work as expected.

My desired functionality is to be able to specify the root key and the communicator key separately. If I don't specify a root key then the plugin should generate a temporary one for me, but then connect using the supplied communicator user/key.

Reproduction Steps

  1. Create a keypair on the host where you're running packer.
  2. Add that key to Digital Ocean.
  3. Create a packer buildfile that specifies the private key file but not the key ID from Digital Ocean
  4. Run packer build
  5. Observe the output (example below)

Plugin and Packer version

Packer: 1.9.4
Plugin: 1.2.0 and up

Simplified Packer Buildfile

variable "deploy_private_key_file" {
  type = string
  default = null
}

variable "digital_ocean_application_image_id" {
  type = string
  default = null
}

build {
  name = "application_server"
  source "source.digitalocean.default" {
    image = var.digital_ocean_application_image_id
    snapshot_name = "backend_server"
    snapshot_regions = ["tor1", "nyc3"]
    ssh_username = "deploy"
    ssh_private_key_file = var.deploy_private_key_file
  }
}

Operating system and Environment details

MacOS 13.6.3

Log Fragments and crash.log files

Full plugin output from my packer run:

Debug mode enabled. Builds will not be parallelized.
application_server.digitalocean.default: output will be in this color.

==> application_server.digitalocean.default: Using existing SSH private key
==> application_server.digitalocean.default: Pausing after run of step 'StepSSHKeyGen'. Press enter to continue. 
==> application_server.digitalocean.default: Pausing after run of step 'nullStep'. Press enter to continue. 
==> application_server.digitalocean.default: Importing SSH public key...
==> application_server.digitalocean.default: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "e362b52b-ac39-4c99-b14f-cb6bf0804dc0") SSH Key is already in use on your account
==> application_server.digitalocean.default: Pausing before cleanup of step 'nullStep'. Press enter to continue. 
==> application_server.digitalocean.default: Pausing before cleanup of step 'StepSSHKeyGen'. Press enter to continue. 
Build 'application_server.digitalocean.default' errored after 20 seconds 184 milliseconds: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "e362b52b-ac39-4c99-b14f-cb6bf0804dc0") SSH Key is already in use on your account

Add ability to specify base image by name

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

Right now builder supports referencing base images only by ID or by Slug. But slug couldn't be used for self-built images, as far as I found in docs.

In current documentation it seems that using image name is possible, but it isn't so - https://github.com/hashicorp/packer-plugin-digitalocean/blob/main/builder/digitalocean/config.go#L43-L47

Use Case(s)

It would allow referencing image without ID for self-built base images.

Potential configuration

Potential References

digitalocean/godo#521

ssh_key_id does not work with ssh_private_key_file in v1.2.0

Overview of the Issue

I am trying to use exisiting ssh key in account. if i specify ssh_key_id and ssh_private_key_file. I am getting following error when i try to create image.

digitalocean.example: output will be in this color.

==> digitalocean.example: Using existing SSH private key
==> digitalocean.example: Importing SSH public key...
==> digitalocean.example: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account
Build 'digitalocean.example' errored after 1 second 304 milliseconds: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account

==> Wait completed after 1 second 304 milliseconds

==> Some builds didn't complete successfully and had errors:
--> digitalocean.example: Error creating temporary SSH key: POST https://api.digitalocean.com/v2/account/keys: 422 (request "3099ae6d-a836-44ab-9449-c41ccf192f45") SSH Key is already in use on your account

==> Builds finished but no artifacts were created.

Reproduction Steps

Steps to reproduce this issue

Plugin and Packer version

From packer version

Packer v1.9.4

Simplified Packer Buildfile

packer {
  required_plugins {
    digitalocean = {
      version = ">= 1.0.0"
      source  = "github.com/digitalocean/digitalocean"
    }
  }
}

source "digitalocean" "example" {
  api_token            = "api_token"
  image                = "ubuntu-23-04-x64"
  region               = "nyc3"
  size                 = "s-1vcpu-1gb"
  ssh_username         = "root"
  ssh_key_id           = key_id
  ssh_private_key_file = "key_path"
}

build {
  sources = ["source.digitalocean.example"]
}

Operating system and Environment details

ubuntu 22.04

Expose optional parameter to disable droplet_agent

Please search the existing issues for relevant feature requests, and use the
reaction feature
(https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
to add upvotes to pre-existing requests.

Community Note

Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request.
Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request.
If you are interested in working on this issue or have submitted a pull request, please leave a comment.

Description

When building a Droplet snapshot using this Packer plugin, the droplet-agent parameter is not exposed. This leads to the agent always being installed in the snapshot, and the Terraform parameter cannot then impact the resulting server (disabling droplet-agent from terraform has no effect).

This was originally reported in digitalocean/terraform-provider-digitalocean#856 .

This plugin should expose an optional parameter that controls whether the droplet_agent parameter is sent during the droplet creation of the packer builder. This should be true by default, similar to the existing Terraform parameter.

Use Case(s)

Users wishing not to include the droplet-agent on their servers should have their wishes respected by the Packer plugin, as the DO API exposes this capability for users.

Potential configuration

Potential References

Add ability to make it an Image (instead of a snapshot)

Description

Hi, thanks for the plugin.
At the moment this is helpful to make the image a Snapshot.
I guess the way of handle this at the moment would be to build a file, upload to Spaces, and then create the image based on the spaces URL. Would be great if this could be done in one step.

Thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.