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

Unable to get Plugin to proceed with installation with Packer v1.3.4 #5

Open
virajamipara opened this issue Apr 16, 2019 · 9 comments

Comments

@virajamipara
Copy link

virajamipara commented Apr 16, 2019

Not working for me even after trying multiple ways:

  • Downloaded the plugin from releases.
  • After renaming it to 'packer-post-processor-vhd', copied it to ~/packer.d/plugins (also tried ~/.packer.d/plugins).
  • Added the post-processor block to generate VHD file from virtualbox-iso artifacts. But, there is no such output (as if the 'vhd' post-processor never ran).

Logs below:

==> virtualbox-iso: Deregistering and deleting VM...
==> virtualbox-iso: Pausing before cleanup of step 'StepSuppressMessages'. Press enter to continue. 
==> virtualbox-iso: Pausing before cleanup of step 'StepHTTPServer'. Press enter to continue. 
==> virtualbox-iso: Pausing before cleanup of step 'StepCreateFloppy'. Press enter to continue. 
==> virtualbox-iso: Pausing before cleanup of step 'StepOutputDir'. Press enter to continue. 
==> virtualbox-iso: Pausing before cleanup of step 'StepDownload'. Press enter to continue. 
==> virtualbox-iso: Pausing before cleanup of step 'StepDownloadGuestAdditions'. Press enter to continue. 
==> virtualbox-iso: Running post-processor: manifest
==> virtualbox-iso: Running post-processor: checksum

So, tried alternate way of installing plugin via Go but got the following error:

$ go get github.com/benwebber/packer-post-processor-vhd
# github.com/benwebber/packer-post-processor-vhd
go/src/github.com/benwebber/packer-post-processor-vhd/main.go:13:34: cannot use new(vhd.PostProcessor) (type *vhd.PostProcessor) as type packer.PostProcessor in argument to server.RegisterPostProcessor:
	*vhd.PostProcessor does not implement packer.PostProcessor (wrong type for PostProcess method)
		have PostProcess(packer.Ui, packer.Artifact) (packer.Artifact, bool, error)
		want PostProcess(context.Context, packer.Ui, packer.Artifact) (packer.Artifact, bool, bool, error)

So, maybe some changes in core Packer code has broken the interface contract here. So is it possible to know which is the latest stable Packer version with which the plugin works nicely.

Also, really thanks for this nice post-processor project. Hope I can make it work for me.

@virajamipara virajamipara changed the title Unable to get Plugin to proceed with installation Unable to get Plugin to proceed with installation with Packer v1.3.4 Apr 16, 2019
@virajamipara
Copy link
Author

virajamipara commented Apr 26, 2019

@attacktac If it helps, you can try the following post-processor:

    {
      "type": "shell-local",
      "inline": [
        "echo '****************************** Generating VHD file ******************************'",
        "VBoxManage clonehd <<input-file>>-disk001.vmdk --format VHD <<output-file-name>>.vhd"
      ]
    }

With VirtualBox installed/present, this should help you to generate a .vhd file from an existing .vmdk. Again, either of builders 'virtualbox-iso' or 'virtualbox-ovf' can help to generate .vmdk file.

Same thing should also be achievable via adding the above command equivalent in the 'vboxmanage_post' block as its a 'VBoxManage' command.

@benwebber
Copy link
Owner

benwebber commented Apr 26, 2019

Thanks for the bug report. It's very likely the internal Packer API changed. I will look at fixing this shortly.

If I recall correctly, the post-processor plugin works with 0.11. You can try that version as a temporary measure. You can download the older version from here:

https://releases.hashicorp.com/packer/

benwebber added a commit that referenced this issue Apr 28, 2019
Packer 1.4.0 introduced breaking changes to the plugin interface[1]:

  1. Builder, provisioner, and post-processor plugins now require a
     `context.Context`.
  2. Post-processor plugins also return a Boolean indicating whether the
     plugin should ignore `keep_input_artifact`.

As of writing, these changes are not documented in the plugin
documentation or release notes[2][3].

References:

  1. hashicorp/packer#7440
  2. https://github.com/hashicorp/packer/blob/4639f92f638a5186e5dcefd733dd1f77ee44de35/website/source/docs/extending/custom-post-processors.html.md
  3. https://github.com/hashicorp/packer/blob/4639f92f638a5186e5dcefd733dd1f77ee44de35/CHANGELOG.md

Fixes: #5 (#5)
@benwebber
Copy link
Owner

Packer 1.4.0 introduced a breaking change to the plugin interface (hashicorp/packer#7440, hashicorp/packer#7581).

I updated the package for the new interface. Could you try running this pre-release version?

https://github.com/benwebber/packer-post-processor-vhd/releases/tag/v1.0.0-rc.1

@virajamipara
Copy link
Author

I tried the darwin release but still could not see the post-processor 'vhd' running nor the .vhd file. I tried keeping the plugin file after renaming it to following places:

  • ~/.packer.d/plugins
  • ~/packer.d/plugins
  • Same place from where I am running my .json template file

@benwebber
Copy link
Owner

If your Packer template is not confidential or sensitive, could you share it here or publish it in a Gist? I'd like to reproduce the issue.

@virajamipara
Copy link
Author

If your Packer template is not confidential or sensitive, could you share it here or publish it in a Gist? I'd like to reproduce the issue.

Well, let me trim down my template so that its sharable. Will test it once again and will share you the template. Quick query though - is it ok to skip the 'provisioners' altogether and still expect the 'vhd' post-processor to generate .vhd from the 'virtualbox-iso' builder's .ovf/.vmdk file?

@benwebber
Copy link
Owner

Well, let me trim down my template so that its sharable. Will test it once again and will share you the template.

Thanks. A minimum working example (e.g., ISO → OVA → VHD) would be great.

Quick query though - is it ok to skip the 'provisioners' altogether and still expect the 'vhd' post-processor to generate .vhd from the 'virtualbox-iso' builder's .ovf/.vmdk file?

Yep, post-processors only need the build artefact. So the template only needs to contain the builders and post-processors configuration.

@virajamipara
Copy link
Author

virajamipara commented May 23, 2019

Hi, apologies for the delayed response. Here is the trimmed but complete JSON file that has workflow: ISO -> OVF -> post-processing to VHD file.

{
  "variables": {
    "iso": "http://repos.del.extreme-ix.org/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso",
    "checksum": "bd43d41e01c2a46b3cb23eb9139dce4b"
  },
  "builders": [
    {
      "type": "virtualbox-iso",
      "iso_url": "{{ user `iso` }}",
      "iso_checksum": "{{ user `checksum` }}",
      "iso_checksum_type": "md5",
      "vm_name": "MyCentOS7",
      "guest_os_type": "RedHat_64",
      "ssh_username": "root",
      "ssh_password": "packer",
      "ssh_port": 22,
      "ssh_wait_timeout": "600s",
      "vboxmanage": [
        ["modifyvm", "{{.Name}}", "--memory", "2048"],
        ["modifyvm", "{{.Name}}", "--cpus", "2"],
        ["modifyvm", "{{.Name}}", "--audio", "none"]
      ],
      "disk_size": "10240",
      "http_directory": "http",
      "boot_command": [
        "<tab> text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks.cfg<enter><wait>"
      ],
      "shutdown_command": "/sbin/halt -p"
    }
  ],
  "post-processors": [
    {
      "type": "vhd",
      "only": ["virtualbox-iso"],
      "force": true,
      "keep_input_artifact": true
    }
  ]
}

Also, the required http/ks.cfg is as follows (password hash is not valid in pasted code - but should not be a problem considering we just want to see build artifacts):

# Run the installer
install

# Use CDROM installation media - ISO based
cdrom

# System language
lang en_US.UTF-8

# Keyboard layouts
keyboard us

# Enable more hardware support
unsupported_hardware

# System timezone
timezone UTC

# Network information
network --bootproto=dhcp --hostname=my-linux
rootpw --plaintext packer

# Creating newuser with sudo capabilities
user --name=newuser --password=user@123 --group=wheel

# System authorization information
auth --enableshadow --passalgo=sha512 --kickstart
firewall --enabled

# Selinux in permissive mode (will be disabled by provisioners)
selinux --permissive

# System bootloader configuration
bootloader --location=mbr

# Run the text install
text

# Skip X config
skipx

# Overwrite the MBR, remove all existing partitions during the installation, zerombr performs installation automatically with no interaction, autopart automatically creates partitions
zerombr
clearpart --all --initlabel
autopart

# Do not run the Setup Agent on first boot
firstboot --disable

# Accept the EULA
eula --agreed

# Reboot the system when the install is complete
reboot

# Packages
%packages --instLangs=en_US.utf8 --nobase --ignoremissing --excludedocs
@core
wget
%end

%post --log=/root/ks.log
yum -y update
yum clean all
%end

After successful completion of packer build the artifacts generated are:

  • MyCentOS7.ovf
  • MyCentOS7-disk001.vmdk

So, no VHD file got generated.

@justinhauer
Copy link

@benwebber any updates on this?

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

No branches or pull requests

4 participants
@benwebber @virajamipara @justinhauer and others