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

fix data source digitalocean-image #162

Closed
briantical opened this issue Sep 19, 2024 · 1 comment · Fixed by #163
Closed

fix data source digitalocean-image #162

briantical opened this issue Sep 19, 2024 · 1 comment · Fixed by #163
Labels

Comments

@briantical
Copy link

Overview of the Issue

Following the example of using the data source digital ocean-image from the official documentation does not work as expected and fails with errors when running packer build . The sample error is as shown below:

Error: Datasource.Execute failed: No image matching found

  on main.pkr.hcl line 1:
  (source code not available)

Error: Unsupported attribute

  on main.pkr.hcl line 9:
  (source code not available)

This object does not have an attribute named "digitalocean-image".

Reproduction Steps

  • Follow the detailed steps when using the data source digitalocean-image as given here.
  • Running packer build . fails with the error as shown above.

Plugin and Packer version

From Packer v1.11.2

Simplified Packer Buildfile

data "digitalocean-image" "example" {
    name_regex = "golden-image-2022.*"
    region     = "nyc3"
    type       = "user"
    latest     = true
}

locals {
    image_id = data.digitalocean-image.example.image_id
}

source "digitalocean" "example" {
    snapshot_name = "updated-golden-image"
    image         = local.image_id
    region        = "nyc3"
    size          = "s-1vcpu-1gb"
    ssh_username  = "root"
}

build {
  sources = ["source.digitalocean.example"]
  provisioner "shell" {
    inline = ["touch /root/provisioned-by-packer"]
  }
}

Operating system and Environment details

MacOs Sonoma 14.6.1, Apple M1

Log Fragments and crash.log files

2024/09/19 03:02:19 [INFO] Packer version: 1.11.2 [go1.21.12 darwin arm64]
2024/09/19 03:02:19 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2024/09/19 03:02:19 [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/briantical/.packerconfig
2024/09/19 03:02:19 [WARN] Config file doesn't exist: /Users/briantical/.packerconfig
2024/09/19 03:02:19 [INFO] Setting cache directory: /Users/briantical/.cache/packer
2024/09/19 03:02:19 [TRACE] listing potential installations for "github.com/digitalocean/digitalocean" that match ">= 1.0.4". plugingetter.ListInstallationsOptions{PluginDirectory:"/Users/briantical/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"darwin", ARCH:"arm64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0x140006fa000)}}, ReleasesOnly:false}}
2024/09/19 03:02:19 [TRACE] Found the following "github.com/digitalocean/digitalocean" installations: [{/Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 v1.4.0 x5.0}]
2024/09/19 03:02:19 [INFO] found external [-packer-default-plugin-name-] builders from digitalocean plugin
2024/09/19 03:02:19 [INFO] found external [import] post-processors from digitalocean plugin
2024/09/19 03:02:19 found external [image] datasource from digitalocean plugin
2024/09/19 03:02:19 [TRACE] listing potential installations for <nil> that match "". plugingetter.ListInstallationsOptions{PluginDirectory:"/Users/briantical/.config/packer/plugins", BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"darwin", ARCH:"arm64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0x14000632000)}}, ReleasesOnly:false}}
2024/09/19 03:02:19 [INFO] found external [chroot ebs ebssurrogate ebsvolume instance] builders from amazon plugin
2024/09/19 03:02:19 [INFO] found external [import] post-processors from amazon plugin
2024/09/19 03:02:19 found external [ami parameterstore secretsmanager] datasource from amazon plugin
2024/09/19 03:02:19 [INFO] found external [-packer-default-plugin-name-] builders from digitalocean plugin
2024/09/19 03:02:19 [INFO] found external [import] post-processors from digitalocean plugin
2024/09/19 03:02:19 found external [image] datasource from digitalocean plugin
2024/09/19 03:02:19 [TRACE] validateValue: not active for auth_key, so skipping
2024/09/19 03:02:19 [TRACE] validateValue: not active for ssh_username, so skipping
2024/09/19 03:02:19 [TRACE] validateValue: not active for image, so skipping
2024/09/19 03:02:19 [TRACE] validateValue: not active for source, so skipping
2024/09/19 03:02:19 [INFO] Starting external plugin /Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 start datasource image
2024/09/19 03:02:19 Starting plugin: /Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 []string{"/Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64", "start", "datasource", "image"}
2024/09/19 03:02:19 Waiting for RPC address for: /Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64
2024/09/19 03:02:19 packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 plugin: 2024/09/19 03:02:19 Plugin address: unix /var/folders/wb/ncnfxqk90tv3321b3tfn1jq80000gn/T/packer-plugin3956078622
2024/09/19 03:02:19 packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 plugin: 2024/09/19 03:02:19 Waiting for connection...
2024/09/19 03:02:19 Received unix RPC address for /Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64: addr is /var/folders/wb/ncnfxqk90tv3321b3tfn1jq80000gn/T/packer-plugin3956078622
2024/09/19 03:02:19 packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 plugin: 2024/09/19 03:02:19 Serving a plugin connection...
2024/09/19 03:02:19 packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 plugin: 2024/09/19 03:02:19 [TRACE] starting datasource image
2024/09/19 03:02:19 [INFO] (telemetry) Starting datasource digitalocean-image
2024/09/19 03:02:19 packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64 plugin: 2024/09/19 03:02:19 [DEBUG] GET https://api.digitalocean.com/v2/images?page=1&per_page=200&private=true
2024/09/19 03:02:20 [INFO] (telemetry) ending digitalocean-image

  on main.pkr.hcl line 1:
  (source code not available)

Error: Unsupported attribute

  on main.pkr.hcl line 9:
  (source code not available)

This object does not have an attribute named "digitalocean-image".

2024/09/19 03:02:20 [INFO] (telemetry) Finalizing.
Error: Datasource.Execute failed: No image matching found

  on main.pkr.hcl line 1:
  (source code not available)

Error: Unsupported attribute

  on main.pkr.hcl line 9:
  (source code not available)

This object does not have an attribute named "digitalocean-image".


2024/09/19 03:02:21 waiting for all plugin processes to complete...
2024/09/19 03:02:21 /Users/briantical/.config/packer/plugins/github.com/digitalocean/digitalocean/packer-plugin-digitalocean_v1.4.0_x5.0_darwin_arm64: plugin process exited
@andrewsomething
Copy link
Member

Hi @briantical,

The first part of the error points to the issue:

Error: Datasource.Execute failed: No image matching found

This data source is used look up the ID of an existing DigitalOcean image on your account. golden-image-2022.* is just an example. You should use the name of an image already on your account.

Since the image was not found, it can not be referenced latter. This causes the second error:

This object does not have an attribute named "digitalocean-image".

I've opened a PR (#163) that adds some additional detail to the example. Hopefully that makes things a bit more clear.

Let us know if this resolved your issue!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants