ethanmdavidson/packer-plugin-git

Plugin issue when starting the build

Closed this issue · 5 comments

Ankhas commented

Here is my script :

packer {
  required_version = ">= 1.8.6"
  required_plugins {
    git = {
      version = ">= 0.3.3"
      source  = "github.com/ethanmdavidson/git"
    }
    virtualbox = {
      version = "1.0.4"
      source  = "github.com/hashicorp/virtualbox"
    }
  }
}

data "git-repository" "cwd" {}

locals {
  build_version = data.git-repository.cwd.head
}

source "virtualbox-iso" "linux-ubuntu" {
  # Virtual Machine Settings
  guest_os_type = "Ubuntu_64"
  cpus          = 2
  memory        = 2048
  disk_size     = 40960

  # Removable Media Settings
  #  http_content = local.data_source_content

  # Boot and Provisioning Settings
  headless     = false
  iso_url      = "https://releases.ubuntu.com/20.04/ubuntu-20.04.6-live-server-amd64.iso"
  iso_checksum = "sha256:b8f31413336b9393ad5d8ef0282717b2ab19f007df2e9ed5196c13d8f9153c8b"
  boot_wait    = "5s"
  boot_command = [
    "<enter><enter><f6><esc><wait> ",
    "autoinstall ds=nocloud-net;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/",
    "<enter><wait>"
  ]
  shutdown_command = "echo 'test' | sudo -S shutdown -P now"

  # Communicator Settings and Credentials
  ssh_username           = "ubuntu"
  ssh_password           = "test"
  ssh_agent_auth         = true
  ssh_timeout            = "30m"
  ssh_handshake_attempts = 1000

  # Export Settings
  output_directory = "./output/virtualbox"
  export_opts = [
    "--manifest",
    "--vsys", "0",
    "--description", "test description",
    "--version", "${local.build_version}"
  ]
  format = "ova"
}


build {
  name = "Build OVA"
  sources = [
    "sources.virtualbox-iso.linux-ubuntu",
  ]
}

When I run command packer build <path-to-my-script>, no message is showed from the Packer output.

If I run PACKER_LOG=1 packer build <path-to-my-script>, here is the output:

2023/04/05 10:23:26 [INFO] Packer version: 1.8.6 [go1.18.9 linux amd64]
2023/04/05 10:23:26 [TRACE] discovering plugins in /usr/bin
2023/04/05 10:23:26 [TRACE] discovering plugins in /home/jean/.config/packer/plugins
2023/04/05 10:23:26 [DEBUG] Discovered plugin: git = /home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64
2023/04/05 10:23:26 [DEBUG] Discovered plugin: docker = /home/jean/.config/packer/plugins/github.com/hashicorp/docker/packer-plugin-docker_v1.0.8_x5.0_linux_amd64
2023/04/05 10:23:26 [DEBUG] Discovered plugin: virtualbox = /home/jean/.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64
2023/04/05 10:23:26 [DEBUG] Discovered plugin: vmware = /home/jean/.config/packer/plugins/github.com/hashicorp/vmware/packer-plugin-vmware_v1.0.7_x5.0_linux_amd64
2023/04/05 10:23:26 [DEBUG] Discovered plugin: vsphere = /home/jean/.config/packer/plugins/github.com/hashicorp/vsphere/packer-plugin-vsphere_v1.1.1_x5.0_linux_amd64
2023/04/05 10:23:26 found external [commit repository tree] datasource from git plugin
2023/04/05 10:23:26 [INFO] found external [-packer-default-plugin-name-] builders from docker plugin
2023/04/05 10:23:26 [INFO] found external [import push save tag] post-processors from docker plugin
2023/04/05 10:23:26 [INFO] found external [iso ovf vm] builders from virtualbox plugin
2023/04/05 10:23:26 [INFO] found external [iso vmx] builders from vmware plugin
2023/04/05 10:23:26 [INFO] found external [clone iso supervisor] builders from vsphere plugin
2023/04/05 10:23:26 [INFO] found external [-packer-default-plugin-name- template] post-processors from vsphere plugin
2023/04/05 10:23:26 [TRACE] discovering plugins in .
2023/04/05 10:23:26 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2023/04/05 10:23:26 [INFO] PACKER_CONFIG env var set; attempting to open config file: /home/jean/.packerconfig
2023/04/05 10:23:26 [WARN] Config file doesn't exist: /home/jean/.packerconfig
2023/04/05 10:23:26 [INFO] Setting cache directory: /home/jean/.cache/packer
2023/04/05 10:23:26 [TRACE] listing potential installations for "github.com/ethanmdavidson/git" that match ">= 0.3.3". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/bin/packer", ".", "/home/jean/.config/packer/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc000b5e600)}}}}
2023/04/05 10:23:26 [TRACE] Found the following "github.com/ethanmdavidson/git" installations: [{/home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64 v0.3.4}]
2023/04/05 10:23:26 found external [commit repository tree] datasource from git plugin
2023/04/05 10:23:26 [TRACE] listing potential installations for "github.com/hashicorp/virtualbox" that match "1.0.4". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/bin/packer", ".", "/home/jean/.config/packer/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"linux", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc000b5e600)}}}}
2023/04/05 10:23:26 [TRACE] Found the following "github.com/hashicorp/virtualbox" installations: [{/home/jean/.config/packer/plugins/github.com/hashicorp/virtualbox/packer-plugin-virtualbox_v1.0.4_x5.0_linux_amd64 v1.0.4}]
2023/04/05 10:23:26 [INFO] found external [iso ovf vm] builders from virtualbox plugin
2023/04/05 10:23:26 [TRACE] Starting external plugin /home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64 start datasource repository
2023/04/05 10:23:26 Starting plugin: /home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64 []string{"/home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64", "start", "datasource", "repository"}
2023/04/05 10:23:26 Waiting for RPC address for: /home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64
2023/04/05 10:23:26 packer-plugin-git_v0.3.4_x5.0_linux_amd64 plugin: 2023/04/05 10:23:26 Plugin address: unix /tmp/packer-plugin833923129
2023/04/05 10:23:26 packer-plugin-git_v0.3.4_x5.0_linux_amd64 plugin: 2023/04/05 10:23:26 Waiting for connection...
2023/04/05 10:23:26 Received unix RPC address for /home/jean/.config/packer/plugins/github.com/ethanmdavidson/git/packer-plugin-git_v0.3.4_x5.0_linux_amd64: addr is /tmp/packer-plugin833923129
2023/04/05 10:23:26 packer-plugin-git_v0.3.4_x5.0_linux_amd64 plugin: 2023/04/05 10:23:26 Serving a plugin connection...
2023/04/05 10:23:26 packer-plugin-git_v0.3.4_x5.0_linux_amd64 plugin: 2023/04/05 10:23:26 [TRACE] starting datasource repository

Hi @Ankhas! I don't have a virtualbox install handy so I can't run your script myself, but based on the logs you've provided I don't see any errors. Can you describe the behavior that you were expecting to see?

Could you also please download and run the repository.pkr.hcl script from the examples directory and let me know what output you get? It should look something like the following:

$ packer build repository.pkr.hcl 
null.git-plugin-test-repository: output will be in this color.

==> null.git-plugin-test-repository: Running local shell script: /tmp/packer-shell2463536863
    null.git-plugin-test-repository: head: main
    null.git-plugin-test-repository: is_clean: true
    null.git-plugin-test-repository: branches: main
    null.git-plugin-test-repository: tags: v0.0.1,v0.0.2,v0.1.0,v0.1.1,v0.2.0,v0.2.1,v0.3.0,v0.3.1,v0.3.2,v0.3.3,v0.3.4
Build 'null.git-plugin-test-repository' finished after 64 milliseconds 823 microseconds.

==> Wait completed after 64 milliseconds 867 microseconds

==> Builds finished. The artifacts of successful builds are:
--> null.git-plugin-test-repository: Did not export anything. This is the null builder

Thanks!

Ankhas commented

Hi @ethanmdavidson!

I have downloaded your repository and run the script repository.pkr.hcl. I'm getting the same output as yours with no issues at all.

In some way, should it be related with my tree structure? In my project I'm running this command:

packer build builds/linux/ubuntu/20-04-lts

And my tree structure is something like that:

.
├── .git
│   ├── branches
│   ├── [...]
│   └── refs
├── packer
│   ├── builds
│   │   └── linux
│   │       └── ubuntu
│   │           └── 20-04-lts
│   │               ├── http
│   │               │   ├── meta-data
│   │               │   └── user-data.pkrtpl.hcl
│   │               ├── linux-ubuntu.auto.pkrvars.hcl
│   │               ├── linux-ubuntu.pkr.hcl
│   │               ├── secrets.auto.pkrvars.hcl
│   │               ├── secrets.auto.pkrvars.hcl.example
│   │               └── variables.pkr.hcl
│   └── README.md
├── .gitignore
└── README.md

If I replace the content of my file build/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl with the content of the file repository.pkr.hcl, the packer build command is still stuck to the log:

2023/04/05 10:23:26 packer-plugin-git_v0.3.4_x5.0_linux_amd64 plugin: 2023/04/05 10:23:26 [TRACE] starting datasource repository

And the build is not processing at all. Even if I press ctrl+c to break the execution, the packer build command is not terminating and let me get back to the shell prompt.

However, I also tried to replace the content of my file build/linux/ubuntu/20-04-lts/linux-ubuntu.pkr.hcl with the content of commit.pkr.hcl and everything works fine.

I'm wondering why the script repository.pkr.hcl is working fine when I ran it in your repository but not in mine.

Thank you! It's very helpful to know that the commit datasource works but not the repository datasource, and that the issue only occurs in your repo. Does your repo happen to be public? It would be very helpful for me to be able to reproduce this myself.

Either way, I'll add some more debug logging to the plugin and see if we can narrow down the issue.

Hi @Ankhas! I've released a new version (0.4.0) that has improved debug logging. Please upgrade to this version, run your script again, and share the logs here.

Closing due to inactivity - please feel free to reopen with more info.