Prerequisites:
- Windows 10 Pro
- WLS, Ubuntu 16.04 (a.k.a.: Bash on Ubuntu on Windows)
- Hyper-V
- Packer (1.0.0, added to path)
- Ansible (2.3.0, installed on WSL)
- qemu-img (2.3.0, added to path)
- Add
ansible.cmd
andansible-playbook.cmd
to yourPATH
- Either set
USER
environment variable in command line or configureansible_user
in packer template to the default user of th WLS
I am using the Hyper-V sample template with the sample preseed
Sample playbook: ansible-bootstrap-ubuntu-16.04.yml
"provisioners": [
{
"type": "ansible",
"playbook_file": "./ansible/ansible-bootstrap-ubuntu-16.04.yml"
}
This step does not work yet: hashicorp/packer#4140 As of packer 1.0.0, There is no support for cmd/powershell step inside post-processors
Convert the vhdx
into qcow2
format
"post-processors": [
{
"type": "shell-local",
"inline": ["qemu-img convert \"output-hyperv-iso\\Virtual Hard Disks\\{{user `vm_name`}}.vhdx\" -O qcow2 ubuntu-xenial.qcow2"]
}
]
This has helped me massively - thanks for sharing 👍