hashicorp / hashicorp/packer-plugin-virtualbox

cd_content is not generating an ISO

Open
#40 4 comments 4 reactions 0 assignees View on GitHub
Dominant language
Go
Stars
29
Forks
45
PR merge metrics
No merged PRs in 30d

Description

_This issue was originally opened by @ctberthiaume in https://github.com/hashicorp/packer/issues/11258 and has been migrated to this repository. The original issue description is below._

---
#### Overview of the Issue

I'd like to use [cd_content](https://www.packer.io/docs/builders/virtualbox/iso#cd_content) with [templatefile](https://www.packer.io/docs/templates/hcl_templates/functions/file/templatefile) to inject templated content during build, specifically to template out user-data and meta-data files for an Ubuntu autoinstall in a Virtualbox VM. The autoinstall works OK when I specify the user-data and meta-data files with [cd_files](https://www.packer.io/docs/builders/virtualbox/iso#cd_files), but if I switch to [cd_content](https://www.packer.io/docs/builders/virtualbox/iso#cd_content) no CD ISO is created. Though not included in this example, I also unsuccessfully tried simply using [file()](https://www.packer.io/docs/templates/hcl_templates/functions/file/file) rather than [templatefile](https://www.packer.io/docs/templates/hcl_templates/functions/file/templatefile).

#### Reproduction Steps

Create these autoinstall files:

`user-data.pkrtpl`
```
#cloud-config
autoinstall:
version: 1
locale: en_US
keyboard:
layout: en
identity:
hostname: ubuntu-server-tpl-${x}
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
username: ubuntu
ssh:
allow-pw: yes
install-server: yes
```

`user-data`
```
#cloud-config
autoinstall:
version: 1
locale: en_US
keyboard:
layout: en
identity:
hostname: ubuntu-server
password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0"
username: ubuntu
ssh:
allow-pw: yes
install-server: yes
```

`meta-data` (empty)
```
```

And this Packer Buildfile

`virtualbox-cd-content-test.pkr.hcl`
```
source "virtualbox-iso" "cd-content-test" {
guest_os_type = "Ubuntu_64"
headless = false
iso_url = "https://releases.ubuntu.com/20.04.3/ubuntu-20.04.3-live-server-amd64.iso"
iso_checksum = "sha256:f8e3086f3cea0fb3fefb29937ab5ed9d19e767079633960ccb50e76153effc98"
ssh_username = "ubuntu"
ssh_password = "ubuntu"
ssh_handshake_attempts = "20"
shutdown_command = "echo 'ubuntu' | sudo -S shutdown -P now"
cd_label = "cidata"
// cd_files = ["meta-data", "user-data"]
cd_content = {
"user-data" = templatefile("user-data.pkrtpl", { x = "foo" })
"meta-data" = ""
}
boot_wait = "5s"
boot_command = [
"",
"linux /casper/vmlinuz autoinstall",
]
cpus = 1
memory = 1024
vboxmanage = [
["modifyvm", "{{.Name}}", "--memory", "1024"],
["modifyvm", "{{.Name}}", "--cpus", "1"],
]
format = "ova"
}

build {
sources = [
"source.virtualbox-iso.cd-content-test"
]
}
```

Run ` PACKER_LOG=1 PACKER_LOG_PATH=packer.log packer build virtualbox-cd-content-test.pkr.hcl`. The install will fail to find a cloud-config file and stall when asking for a language. The [log](https://gist.github.com/ctberthiaume/57ff6f4ed71939d64bde04439e6a8af1) shows that "No CD files specified. CD disk will not be made." on line 50.

Uncomment the `cd_files = ["meta-data", "user-data"]` line and comment out the `cd_content` block, then run the same test again and the install will complete as expected with no interaction necessary. The [log](https://gist.github.com/ctberthiaume/bdc7832727f74ca66762d00e17c895a5) shows "Wrote 316 bytes to user-data" on line 54.

### Packer version

Packer v1.7.4

### Simplified Packer Buildfile

See "Reproduction Steps" above.

### Operating system and Environment details

Host OS: MacOS 11.5.2

Virtualbox version: 6.1.26 r145957

### Log Fragments and crash.log files
* [cd_content log](https://gist.github.com/ctberthiaume/57ff6f4ed71939d64bde04439e6a8af1)
* [cd_files log](https://gist.github.com/ctberthiaume/bdc7832727f74ca66762d00e17c895a5)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.