Open virajamipara opened 5 years ago
@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.
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:
Packer 1.4.0 introduced a breaking change to the plugin interface (https://github.com/hashicorp/packer/issues/7440, https://github.com/hashicorp/packer/issues/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
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:
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.
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?
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.
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:
So, no VHD file got generated.
@benwebber any updates on this?
Not working for me even after trying multiple ways:
Logs below:
So, tried alternate way of installing plugin via Go but got the following 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.