Dmitry Samoylik
63596b617d
|
2 months ago | |
---|---|---|
ansible | 2 months ago | |
http | 2 months ago | |
.gitignore | 1 year ago | |
LICENSE | 1 year ago | |
README.md | 11 months ago | |
cloud-images-build.sh | 2 months ago | |
msvsphere-8-gencloud.pkr.hcl | 3 months ago | |
msvsphere-8-vagrant.pkr.hcl | 8 months ago | |
msvsphere-8-yandexcloud.pkr.hcl | 3 months ago | |
msvsphere-9-gencloud.pkr.hcl | 11 months ago | |
msvsphere-9-ovf.pkr.hcl | 2 months ago | |
msvsphere-9-vagrant.pkr.hcl | 1 year ago | |
msvsphere-9-yandexcloud.pkr.hcl | 11 months ago | |
packer-environment.pkr.hcl | 2 months ago | |
variables.pkr.hcl | 2 months ago |
README.md
MSVSphere Cloud Images
Packer templates and configuration files for building MSVSphere images for various cloud platforms.
Build environment configuration
Supported operating systems:
- MSVSphere 9 and other EL9-compatible distributions
- Fedora
First install Ansible, which we use for virtual machines provisioning:
$ dnf install ansible-core
Then follow the Packer installation instructions. Check the packer-environment.pkr.hcl file for the required Packer version.
Alternatively, you can install a Packer binary from a Yandex
mirror: just download a
latest version archive and unzip it somewhere in PATH (e.g. ~/.local/bin
).
Verify that Packer works:
$ packer version
1.10.0
In order to install required Packer plugins run the following command in the project root:
$ packer init -upgrade .
Dependently on your network configuration, you may also need to open the 8000-9000 TCP port range so that Packer can serve kickstart files to VMs:
$ firewall-cmd --zone=public --add-port=8000-9000/tcp --permanent
$ firewall-cmd --reload
You will also need to install either QEMU/KVM or VirtualBox or VMWare Workstation, depending on what types of images you are going to build.
For VirtualBox and VMWare Workstation just follow the official site documentation.
The QEMU/KVM installation instructions are provided below:
# for MSVSphere 9
$ dnf install edk2-ovmf libvirt libvirt-daemon-kvm
# for Fedora
$ dnf install @virtualization
$ dnf install edk2-ovmf
Building images
In order to build an image use the following command syntax:
$ packer build -only=${BUILDER}.${CONFIGURATION} .
where ${BUILDER}
is a Packer builder (e.g. virtualbox-iso
) and
${CONFIGURATION}
is an image configuration name (e.g.
msvsphere-9-vagrant-x86_64
).
On Fedora you might need to provide extra options because it has different paths for qemu-kvm and edk2 firmware:
$ packer build -var qemu_binary=/usr/bin/qemu-kvm \
-var uefi_ovmf_code=/usr/share/OVMF/OVMF_CODE.fd \
-var uefi_ovmf_vars=/usr/share/OVMF/OVMF_VARS.fd \
-only=${BUILDER}.${CONFIGURATION} .
A graphical VM console is disabled by default, but you can enable it for
debugging purposes by setting the headless
variable to false
:
$ packer build -only=vmware-iso.msvsphere-9-vagrant-x86_64 \
-var headless=false .
See the variables.pkr.hcl file for other supported variables.
Building Generic Cloud images
Generic Cloud image build command:
$ packer build -only=qemu.msvsphere-9-gencloud-x86_64 .
Building Vagrant boxes
VirtualBox Vagrant box build command:
$ packer build -only=virtualbox-iso.msvsphere-9-vagrant-x86_64 .
VMWare Vagrant box build command:
$ packer build -only=vmware-iso.msvsphere-9-vagrant-x86_64 .
Debugging image builds
Use PACKER_LOG=1
environment variable definition to get extra debug output
from Packer:
$ PACKER_LOG=1 packer build ...
other Packer debugging techniques are described in the Packer documentation.
Add -vvvv
flag to the Ansible's extra_arguments
block in a Packer config
in order to get verbose output from Ansible:
build {
provisioner "ansible" {
...
extra_arguments = [..., "-vvvv"]
}
}
Additionally, you can connect to Packer's VNC session using a VNC client. For TigerVNC you will need to enable the following settings:
- Input -> View only (ignore mouse and keyboard)
- Misc -> Shared (don't disconnect other viewers)
By default Packer is running a VNC server on a random TCP port in the 5900:6000 range. But for remote build environments it might be useful to use a specific port so that you can configure a firewall easily:
$ packer build ... -var vnc_bind_address=0.0.0.0 -var vnc_port_min=5900 \
-var vnc_port_max=5900 .
License
Licensed under the MIT license, see the LICENSE file for details.