From ee25c7b42bef418bd9773e2bc2277b8734e724d7 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Thu, 31 Dec 2020 00:02:37 -0800 Subject: [PATCH 1/6] Add start of centos 8 and ubuntu 20.04 examples --- examples/README.md | 0 examples/centos8.json | 42 +++++ examples/http/centos6-ks.cfg | 48 ----- examples/http/{ => centos8}/ks-centos8.cfg | 9 +- examples/http/ks-1804-minimalvm.cfg | 199 --------------------- examples/http/ubuntu-2004/meta-data | 0 examples/http/ubuntu-2004/user-data | 11 ++ examples/ubuntu-2004.json | 50 ++++++ 8 files changed, 109 insertions(+), 250 deletions(-) create mode 100644 examples/README.md create mode 100644 examples/centos8.json delete mode 100644 examples/http/centos6-ks.cfg rename examples/http/{ => centos8}/ks-centos8.cfg (88%) delete mode 100644 examples/http/ks-1804-minimalvm.cfg create mode 100644 examples/http/ubuntu-2004/meta-data create mode 100644 examples/http/ubuntu-2004/user-data create mode 100644 examples/ubuntu-2004.json diff --git a/examples/README.md b/examples/README.md new file mode 100644 index 0000000..e69de29 diff --git a/examples/centos8.json b/examples/centos8.json new file mode 100644 index 0000000..b4c3b6b --- /dev/null +++ b/examples/centos8.json @@ -0,0 +1,42 @@ +{ + "variables": { + "sr_name": "", + "sr_iso_name": "", + "remote_host": "{{env `XAPI_HOST`}}", + "remote_username": "{{env `XAPI_USERNAME`}}", + "remote_password": "{{env `XAPI_PASSWORD`}}" + }, + "builders": [ + { + "type": "xenserver-iso", + "sr_name": "{{user `sr_name`}}", + "sr_iso_name": "{{user `sr_iso_name`}}", + "remote_host": "{{user `remote_host`}}", + "remote_username": "{{user `remote_username`}}", + "remote_password": "{{user `remote_password`}}", + "vm_memory": "4096", + "boot_command": [ + " text ks=http://{{ .HTTPIP }}:{{ .HTTPPort }}/ks-centos8.cfg" + ], + "boot_wait": "10s", + "disk_size": 40960, + "http_directory": "examples/http/centos8", + "iso_checksum": "07a8e59c42cc086ec4c49bdce4fae5a17b077dea", + "iso_checksum_type": "sha1", + "iso_url": "http://mirrors.ocf.berkeley.edu/centos/8.3.2011/isos/x86_64/CentOS-8.3.2011-x86_64-boot.iso", + "iso_name": "CentOS-8.3.2011-x86_64-boot.iso", + "tools_iso_name": "guest-tools.iso", + "vm_other_config": { + "conversionvm":"true" + }, + "output_directory": "packer-centos-8.3-x86_64-xenserver", + "shutdown_command": "/sbin/halt", + "ssh_username": "vagrant", + "ssh_password": "vagrant", + "ssh_wait_timeout": "10000s", + "vm_name": "packer-centos-8.3-x86_64-{{isotime}}", + "vm_description": "Build time: {{isotime}}", + "keep_vm": "always" + } + ] +} diff --git a/examples/http/centos6-ks.cfg b/examples/http/centos6-ks.cfg deleted file mode 100644 index 1c9a165..0000000 --- a/examples/http/centos6-ks.cfg +++ /dev/null @@ -1,48 +0,0 @@ -install -cdrom -lang en_US.UTF-8 -keyboard us -unsupported_hardware -network --bootproto=dhcp -rootpw --iscrypted $1$DIlig7gp$FuhFdeHj.R1VrEzZsI4uo0 -firewall --disabled -authconfig --enableshadow --passalgo=sha512 -selinux --permissive -timezone UTC -bootloader --location=mbr -text -skipx -zerombr -clearpart --all --initlabel -autopart -auth --useshadow --enablemd5 -firstboot --disabled -reboot - -%packages --ignoremissing -@Base -@Core -@Development Tools -openssl-devel -readline-devel -zlib-devel -kernel-devel -vim -wget -%end - -%post -yum -y update - -# update root certs -wget -O/etc/pki/tls/certs/ca-bundle.crt http://curl.haxx.se/ca/cacert.pem - -# vagrant -groupadd vagrant -g 999 -useradd vagrant -g vagrant -G wheel -u 900 -s /bin/bash -echo "vagrant" | passwd --stdin vagrant - -# sudo -echo "vagrant ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers -sed -i "s/^.*requiretty/#Defaults requiretty/" /etc/sudoers -%end diff --git a/examples/http/ks-centos8.cfg b/examples/http/centos8/ks-centos8.cfg similarity index 88% rename from examples/http/ks-centos8.cfg rename to examples/http/centos8/ks-centos8.cfg index 6a8f495..5556361 100644 --- a/examples/http/ks-centos8.cfg +++ b/examples/http/centos8/ks-centos8.cfg @@ -1,5 +1,8 @@ install -cdrom +# TODO: Figure out why cdrom does not work +# cdrom +# TODO: parameterize this from the packer config file +url --url="http://mirror.centos.org/centos/8.3.2011/BaseOS/x86_64/os/" lang en_US.UTF-8 keyboard us network --bootproto=dhcp @@ -21,8 +24,8 @@ user --name=vagrant --plaintext --password=vagrant --groups=wheel reboot %packages --ignoremissing --excludedocs -@Base -@Core +@base +@core @Development Tools openssh-clients sudo diff --git a/examples/http/ks-1804-minimalvm.cfg b/examples/http/ks-1804-minimalvm.cfg deleted file mode 100644 index f6e4f60..0000000 --- a/examples/http/ks-1804-minimalvm.cfg +++ /dev/null @@ -1,199 +0,0 @@ -# -#Kickstart template for Ubuntu -#Platform: x86-64 -# -# Customized for Server 18.04 minimal vm install -# -# See README.mkd for usage - -# Load the minimal server preseed off cdrom -preseed preseed/file string /cdrom/preseed/ubuntu-server-minimalvm.seed - -# OPTIONAL: Change hostname from default 'preseed' -# If your DHCP hands out a hostname that will take precedence over this -# see: https://bugs.launchpad.net/ubuntu/+source/preseed/+bug/1452202 -#preseed netcfg/hostname string minimal-vm - -# Use local proxy -# Setup a server with apt-cacher-ng and enter that hostname here -#preseed mirror/http/proxy string http://my-local-cache:3142/ - -#System language -lang en_US - -#Language modules to install -langsupport en_US - -#System keyboard -keyboard us - -#System mouse -mouse - -#System timezone -timezone America/New_York - -#Root password -rootpw --disabled - -#Initial user (user with sudo capabilities) -user ubuntu --fullname "Ubuntu" --password ChangeMe - -#Reboot after installation -reboot - -#Use text mode install -text - -#Install OS instead of upgrade -install - -#Installation media -cdrom - -#Change console size to 1024x768x24 -preseed debian-installer/add-kernel-opts string "vga=792" - -#System bootloader configuration -bootloader --location=mbr - -#Clear the Master Boot Record -zerombr yes - -#Partition clearing information -# `--all` will give message in install log about only clearing first drive but -# this is still needed -clearpart --all --initlabel - -#Advanced partition -# The last lv specified will take up the remaining space of the vg. To get -# around that add up all your disk sizes and set this value. It appears to -# factor in the size of non lvm partitions as well -preseed partman-auto-lvm/guided_size string 8192MB -part /boot --fstype=ext4 --size=512 --asprimary -part pv.1 --grow --size=1 --asprimary -volgroup vg0 pv.1 -logvol / --fstype=ext4 --name=root --vgname=vg0 --size=1024 -logvol /usr --fstype=ext4 --name=usr --vgname=vg0 --size=2048 -logvol /var --fstype=ext4 --name=var --vgname=vg0 --size=1536 -logvol /var/log --fstype=ext4 --name=var_log --vgname=vg0 --size=512 -logvol swap --name=swap --vgname=vg0 --size=2048 --maxsize=2048 -logvol /home --fstype=ext4 --name=home --vgname=vg0 --size=512 - -# Don't install recommended items by default -# This will also be set for built system at -# /etc/apt/apt.conf.d/00InstallRecommends -preseed base-installer/install-recommends boolean false - -#System authorization infomation -auth --useshadow - -#Network information -# If the system has a single interface the '--device' option isn't needed. If -# you do use it remember that in 18.04 the device names are different. For -# example I was seeing enp0s3 as the interface name. I haven't tested this -# but you should be able to specify 'interface=enp0s3' as a boot paramater and -# it will be passed through to installer. I have tested setting the device to -# 'auto' will have it automatically pick the first active interface -#network --bootproto=dhcp --device=enp0s3 -network --bootproto=dhcp --device=auto - -#Firewall configuration -# Not supported by ubuntu -#firewall --disabled --trust=eth0 --ssh - - -# Policy for applying updates. May be "none" (no automatic updates), -# "unattended-upgrades" (install security updates automatically), or -# "landscape" (manage system with Landscape). -preseed pkgsel/update-policy select unattended-upgrades - -#Do not configure the X Window System -skipx - -# Additional packages to install -# - Most of these would have installed if it wasn't for turning off -# install-recommends -# - software-properties-common provides add-apt-repository which is needed for -# adding additional PPAs. You can remove that if you don't plan on -# installing anything. The %post script needs it for adding git -# - Starting in 16.04 Ubuntu no longer installs python v2.7 by default. -# Instead the default version of python is v3.x. If you still need v2.7 -# then add the `python` package to this list -# - Uncomment the open-vm-tools line if this is going to run in vmware and are -# not going to use vmware-tools that's distributed with it. Don't think the -# --no-install-recommends is needed to not install desktop tools but doesn't -# hurt anything -%packages -# -- required for %post -- -vim -software-properties-common -# -- pretty much required -- -gpg-agent # apt-key needs this when piping certs in through stdin -curl -openssh-server -net-tools # this includes commands like ifconfig and netstat -wget -man -# -- additional packages you'll likely want -- -#open-vm-tools --no-install-recommends # only needed on vmware vms -#bash-completion # personally I always install it but not everyone uses bash -#chrony # default time server in 18.04. systemd will manage time if this doesn't -#haveged # helps keep entropy pool full on VMs - - -%post -# -- begin security hardening -- -# Change default umask from 022 to 027 (not world readable) -sed -i -e 's/^\(UMASK\W*\)[0-9]\+$/\1027/' /etc/login.defs - -# Add noatime to / -sed -i -e 's/\(errors=remount-ro\)/noatime,\1/' /etc/fstab -# Add noatime and nodev to everything else -sed -i -e 's/\(boot.*defaults\)/\1,noatime,nodev/' /etc/fstab -sed -i -e 's/\(home.*defaults\)/\1,noatime,nodev/' /etc/fstab -sed -i -e 's/\(usr.*defaults\)/\1,noatime,nodev/' /etc/fstab -# Remove nodev from this one if it causes issues for you -sed -i -e 's/\(var .*defaults\)/\1,noatime,nodev/' /etc/fstab -# Add noatime, nodev, and noexec to /var/log -sed -i -e 's/\(var\/log .*defaults\)/\1,noatime,nodev,noexec/' /etc/fstab -# Add line to enable noexec on /dev/shm -echo "none /dev/shm tmpfs defaults,noexec,nosuid,nodev 0 0" >>/etc/fstab -# -- end security hardening -- - -# Set some defaults for apt to keep things tidy -cat > /etc/apt/apt.conf.d/90local <<"_EOF_" -APT::Periodic::Update-Package-Lists "1"; -APT::Periodic::Unattended-Upgrade "1"; -APT::Periodic::AutocleanInterval "1"; -APT::Periodic::MaxSize "200"; -Unattended-Upgrade::Remove-Unused-Dependencies "true"; -#Acquire::http::Proxy "http://my-local-cache:3142"; -_EOF_ - -# -- begin vim package customizations -- -echo "set background=dark" >>/etc/vim/vimrc.local -# -- end vim package customizations -- - -# -- begin install git from 'Ubuntu Git Maintainers' PPA -- -add-apt-repository -y ppa:git-core/ppa -apt-get -qq -y update -apt-get -qq -y install git -# -- end install git from 'Ubuntu Git Maintainers' PPA -- - -# -- begin set xdg base directories -- -cat > /etc/profile.d/xdg_basedir.sh <<"_EOF_" -# Set XDG base directory global variables -# XDG_RUNTIME_HOME is set on user login -export XDG_DATA_HOME="${XDG_DATA_HOME:-"${HOME}/.local/share"}" -export XDG_CONFIG_HOME="${XDG_CONFIG_HOME:-"${HOME}/.config"}" -export XDG_CACHE_HOME="${XDG_CACHE_HOME:-"${HOME}/.cache"}" -_EOF_ -chmod 0644 /etc/profile.d/xdg_basedir.sh -# -- end set xdg base directories -- - -# Clean up -apt-get -qq -y autoremove -apt-get clean -rm -f /var/cache/apt/*cache.bin -rm -rf /var/lib/apt/lists/* diff --git a/examples/http/ubuntu-2004/meta-data b/examples/http/ubuntu-2004/meta-data new file mode 100644 index 0000000..e69de29 diff --git a/examples/http/ubuntu-2004/user-data b/examples/http/ubuntu-2004/user-data new file mode 100644 index 0000000..9b6db74 --- /dev/null +++ b/examples/http/ubuntu-2004/user-data @@ -0,0 +1,11 @@ +#cloud-config +autoinstall: + version: 1 + identity: + hostname: ubuntu-server + # This is the crypted pass of 'ubuntu' + password: "$6$exDY1mhS4KUYCE/2$zmn9ToZwTKLhCw.b4/b.ZRTIZM30JZ4QrOQ2aOXJ8yk96xpcCof0kxKwuX1kqLG/ygbJ1f8wxED22bTL4F46P0" + username: testuser + ssh: + install-server: yes + allow-pw: yes diff --git a/examples/ubuntu-2004.json b/examples/ubuntu-2004.json new file mode 100644 index 0000000..1d23836 --- /dev/null +++ b/examples/ubuntu-2004.json @@ -0,0 +1,50 @@ +{ + "variables": { + "sr_name": "", + "sr_iso_name": "", + "remote_host": "{{env `XAPI_HOST`}}", + "remote_username": "{{env `XAPI_USERNAME`}}", + "remote_password": "{{env `XAPI_PASSWORD`}}" + }, + "builders": [ + { + "type": "xenserver-iso", + "sr_name": "{{user `sr_name`}}", + "sr_iso_name": "{{user `sr_iso_name`}}", + "remote_host": "{{user `remote_host`}}", + "remote_username": "{{user `remote_username`}}", + "remote_password": "{{user `remote_password`}}", + "tools_iso_name": "guest-tools.iso", + "boot_command": [ + " autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/", + " autoinstall ds=nocloud-net;s=http://{{ .HTTPIP }}:{{ .HTTPPort }}/" + ], + "boot_wait": "10s", + "disk_size": 10960, + "http_directory": "examples/http/ubuntu-2004", + "iso_checksum": "443511f6bf12402c12503733059269a2e10dec602916c0a75263e5d990f6bb93", + "iso_checksum_type": "sha256", + "iso_url": "http://releases.ubuntu.com/20.04/ubuntu-20.04.1-live-server-amd64.iso", + "iso_name": "ubuntu-20.04.1-live-server-amd64.iso", + "vm_other_config": { + "conversionvm":"true" + }, + "network_names": [ + "Host internal management network", + "Pool-wide network associated with eth0" + ], + "output_directory": "packer-ubuntu-2004-x86_64-xenserver", + "shutdown_command": "/sbin/halt", + "ssh_username": "testuser", + "ssh_password": "ubuntu", + "ssh_wait_timeout": "60000s", + "ssh_timeout": "60000s", + "vm_name": "packer-ubuntu-2004-x86_64", + "vm_description": "Build time: {{isotime}}", + "disk_size": "20000", + "vm_memory": "4096", + "keep_vm": "always", + "ssh_handshake_attempts": "10000" + } + ] +} From 04120e891a8fd6df4ce49cde17ff6d9669e2bc0f Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Sat, 2 Jan 2021 23:09:19 -0800 Subject: [PATCH 2/6] Ensure required LockingMode parameter is set on VIF and fail the packer build if vif is failed to be created --- builder/xenserver/common/client.go | 15 +++++---------- builder/xenserver/iso/step_create_instance.go | 3 ++- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/builder/xenserver/common/client.go b/builder/xenserver/common/client.go index a7dca6d..6341986 100644 --- a/builder/xenserver/common/client.go +++ b/builder/xenserver/common/client.go @@ -609,22 +609,17 @@ func (self *VM) SetPlatform(params map[string]string) (err error) { } func ConnectNetwork(c *Connection, networkRef xenapi.NetworkRef, vmRef xenapi.VMRef, device string) (*xenapi.VIFRef, error) { - // Create the VIF - // vif_rec["other_config"] = make(xmlrpc.Struct) - // vif_rec["qos_algorithm_params"] = make(xmlrpc.Struct) - vif, err := c.client.VIF.Create(c.session, xenapi.VIFRecord{ - Network: networkRef, - VM: vmRef, - MAC: "", - Device: device, - MTU: 1504, - QosAlgorithmType: "", + Network: networkRef, + VM: vmRef, + Device: device, + LockingMode: xenapi.VifLockingModeNetworkDefault, }) if err != nil { return nil, err } + log.Printf("Created the following VIF: %s", vif) return &vif, nil } diff --git a/builder/xenserver/iso/step_create_instance.go b/builder/xenserver/iso/step_create_instance.go index 2b39a87..69bfe3c 100644 --- a/builder/xenserver/iso/step_create_instance.go +++ b/builder/xenserver/iso/step_create_instance.go @@ -170,7 +170,8 @@ func (self *stepCreateInstance) Run(state multistep.StateBag) multistep.StepActi _, err = xscommon.ConnectNetwork(c, network, instance, "0") if err != nil { - ui.Say(err.Error()) + ui.Error(fmt.Sprintf("Failed to create VIF with error: %v", err)) + return multistep.ActionHalt } } else { From a5a2b491abb65c9a30260ded3948ac3cf8e375f6 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Sat, 2 Jan 2021 23:52:00 -0800 Subject: [PATCH 3/6] Update documentation with changes from upstream, fix shutdown command for examples --- docs/builders/xenserver-iso.html.markdown | 49 ++--------------------- examples/README.md | 33 +++++++++++++++ examples/centos8.json | 2 +- examples/ubuntu-2004.json | 6 +-- 4 files changed, 39 insertions(+), 51 deletions(-) diff --git a/docs/builders/xenserver-iso.html.markdown b/docs/builders/xenserver-iso.html.markdown index 0108a14..687ad5f 100644 --- a/docs/builders/xenserver-iso.html.markdown +++ b/docs/builders/xenserver-iso.html.markdown @@ -2,7 +2,7 @@ layout: "docs" page_title: "XenServer Builder (from an ISO)" description: |- - The XenServer Packer builder is able to create XenServer virtual machines and export them either as an XVA or a VDI, starting from an ISO image. + The XenServer Packer builder is able to create XenServer virtual machines and export them either as an XVA or a VDI and create VM templates starting from an ISO image. --- # XenServer Builder (from an ISO) @@ -18,32 +18,6 @@ the OS, then shutting it down. The result of the XenServer builder is a directory containing all the files necessary to run the virtual machine portably. -## Basic Example - -Here is a basic example. This example is not functional. Even when the -`remote_*` fields have been completed, it will start the OS installer but then -fail because we don't provide the preseed file for Ubuntu to self-install. -Still, the example serves to show the basic configuration: - -```javascript -{ - "type": "xenserver-iso", - "remote_host": "your-server.example.com", - "remote_username": "root", - "remote_password": "password", - "iso_url": "http://releases.ubuntu.com/12.04/ubuntu-12.04.5-server-amd64.iso", - "iso_checksum": "769474248a3897f4865817446f9a4a53", - "iso_checksum_type": "md5", - "ssh_username": "packer", - "ssh_password": "packer", - "ssh_wait_timeout": "30s", - "shutdown_command": "echo 'packer' | sudo -S shutdown -P now" -} -``` - -It is important to add a `shutdown_command`. By default Packer forcibly halts the -virtual machine and the file system may not be sync'd. Thus, changes made in a -provisioner might not be saved. ## Configuration Reference @@ -69,7 +43,7 @@ each category, the available options are alphabetized and described. If this is an HTTP URL, Packer will download it and cache it between runs. -* `remote_host` (string) - The host of the remote machine. +* `remote_host` (string) - The host of the Xenserver / XCP-ng pool primary. Typically these will be specified through environment variables as seen in the [examples](examples/centos8.json). * `remote_username` (string) - The XenServer username used to access the remote machine. @@ -85,7 +59,7 @@ each category, the available options are alphabetized and described. be to type just enough to initialize the operating system installer. Special keys can be typed as well, and are covered in the section below on the boot command. If this is not specified, it is assumed the installer will start - itself. + itself. See the [Ubuntu](examples/ubuntu-2004.json) and [centos](examples/centos8.json) examples to see how these are used to launch autoinstall and kickstart respectively. * `boot_wait` (string) - The time to wait after booting the initial virtual machine before typing the `boot_command`. The value of this should be @@ -278,19 +252,4 @@ The available variables are: configuration parameter. If `http_directory` isn't specified, these will be blank! -Example boot command. This is actually a working boot command used to start -an Ubuntu 12.04 installer: - -```javascript -[ - "<esc><esc><enter><wait>", - "/install/vmlinuz noapic ", - "preseed/url=http://{{ .HTTPIP }}:{{ .HTTPPort }}/preseed.cfg ", - "debian-installer=en_US auto locale=en_US kbd-chooser/method=us ", - "hostname={{ .Name }} ", - "fb=false debconf/frontend=noninteractive ", - "keyboard-configuration/modelcode=SKIP keyboard-configuration/layout=USA ", - "keyboard-configuration/variant=USA console-setup/ask_detect=false ", - "initrd=/install/initrd.gz -- <enter>" -] -``` +See the [examples](examples/) for working boot commands. diff --git a/examples/README.md b/examples/README.md index e69de29..b0d3b61 100644 --- a/examples/README.md +++ b/examples/README.md @@ -0,0 +1,33 @@ +## Examples + +In order for new users to get up and running with the packer builder, a few examples of building a machine image with popular distros have been created. At the time of this writing there are examples for the latest Ubuntu (20.04) and Centos (8.3) releases. Please open an issue if you'd like to see an example for another distro. + +In order to see an exhaustive list of configuration options for the packer builder please see the [following documentation](docs/builders/xenserver-iso.html.markdown). This doc will focus on the details relevant to the particular distro. + +### Running the examples + +In order to run this example you will need to perform the following steps: +1. Ensure that you are running packer from a machine on the same subnet as the VM packer will be launching. This can be overriden with the `network_names` builder configuration if needed. +2. Export the `XAPI_HOST`, `XAPI_USERNAME` and `XAPI_PASSWORD` environment variables to the current shell. Note: The `XAPI_HOST` must be the resource pool primary. +3. Run the `packer build` command specifying the storage repositories to use for the ISO upload and for the VM created during the build. + +``` +# Replace sr_name and sr_iso_name with your storage repositories names +packer build -debug --var sr_name='Local storage' --var sr_iso_name=LocalISO examples/centos8.json + +# Do the same variable replacement for the ubuntu example as well. +packer build -debug --var sr_name='Local storage' --var sr_iso_name=LocalISO examples/ubuntu-2004.json +``` + +### Ubuntu + +The Ubuntu example uses the [autoinstall tool](https://ubuntu.com/server/docs/install/autoinstallhttps://ubuntu.com/server/docs/install/autoinstall) to configure the VM template. Please see the [autoinstall docs](https://ubuntu.com/server/docs/install/autoinstall-reference) for an exhaustive list of what is supported. + +Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [user-data](examples/http/ubuntu-2004/user-data) and [meta-data](examples/http/ubuntu-2004/meta-data) for autoinstall must be present. + + +### Centos + +The centos example uses kickstart to configure the VM template. Please see the [kickstart documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax) for the options that are supported. + +Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [kickstart config](examples/http/centos8/ks-centos8.cfg) file must be present. diff --git a/examples/centos8.json b/examples/centos8.json index b4c3b6b..c0c778b 100644 --- a/examples/centos8.json +++ b/examples/centos8.json @@ -30,7 +30,7 @@ "conversionvm":"true" }, "output_directory": "packer-centos-8.3-x86_64-xenserver", - "shutdown_command": "/sbin/halt", + "shutdown_command": "/sbin/shutdown", "ssh_username": "vagrant", "ssh_password": "vagrant", "ssh_wait_timeout": "10000s", diff --git a/examples/ubuntu-2004.json b/examples/ubuntu-2004.json index 1d23836..b06b3b3 100644 --- a/examples/ubuntu-2004.json +++ b/examples/ubuntu-2004.json @@ -29,12 +29,8 @@ "vm_other_config": { "conversionvm":"true" }, - "network_names": [ - "Host internal management network", - "Pool-wide network associated with eth0" - ], "output_directory": "packer-ubuntu-2004-x86_64-xenserver", - "shutdown_command": "/sbin/halt", + "shutdown_command": "/sbin/shutdown", "ssh_username": "testuser", "ssh_password": "ubuntu", "ssh_wait_timeout": "60000s", From f2d56718126c26a1890c5dbaf9822ff0f86d829c Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Sat, 2 Jan 2021 23:54:55 -0800 Subject: [PATCH 4/6] Specify relative addressing for markdown links --- docs/builders/xenserver-iso.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/builders/xenserver-iso.html.markdown b/docs/builders/xenserver-iso.html.markdown index 687ad5f..a2332d9 100644 --- a/docs/builders/xenserver-iso.html.markdown +++ b/docs/builders/xenserver-iso.html.markdown @@ -43,7 +43,7 @@ each category, the available options are alphabetized and described. If this is an HTTP URL, Packer will download it and cache it between runs. -* `remote_host` (string) - The host of the Xenserver / XCP-ng pool primary. Typically these will be specified through environment variables as seen in the [examples](examples/centos8.json). +* `remote_host` (string) - The host of the Xenserver / XCP-ng pool primary. Typically these will be specified through environment variables as seen in the [examples](../../examples/centos8.json). * `remote_username` (string) - The XenServer username used to access the remote machine. @@ -59,7 +59,7 @@ each category, the available options are alphabetized and described. be to type just enough to initialize the operating system installer. Special keys can be typed as well, and are covered in the section below on the boot command. If this is not specified, it is assumed the installer will start - itself. See the [Ubuntu](examples/ubuntu-2004.json) and [centos](examples/centos8.json) examples to see how these are used to launch autoinstall and kickstart respectively. + itself. See the [Ubuntu](../../examples/ubuntu-2004.json) and [centos](../../examples/centos8.json) examples to see how these are used to launch autoinstall and kickstart respectively. * `boot_wait` (string) - The time to wait after booting the initial virtual machine before typing the `boot_command`. The value of this should be @@ -252,4 +252,4 @@ The available variables are: configuration parameter. If `http_directory` isn't specified, these will be blank! -See the [examples](examples/) for working boot commands. +See the [examples](../../examples/) for working boot commands. From a69d19895bfc493f0b2198d16cbda8bb2b7b9086 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Sat, 2 Jan 2021 23:58:22 -0800 Subject: [PATCH 5/6] Fixing more links --- docs/builders/xenserver-iso.html.markdown | 2 +- examples/README.md | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/builders/xenserver-iso.html.markdown b/docs/builders/xenserver-iso.html.markdown index a2332d9..270b364 100644 --- a/docs/builders/xenserver-iso.html.markdown +++ b/docs/builders/xenserver-iso.html.markdown @@ -244,7 +244,7 @@ will be replaced by the proper key: is useful if you have to generally wait for the UI to update before typing more. In addition to the special keys, each command to type is treated as a -[configuration template](/docs/templates/configuration-templates.html). +configuration template. The available variables are: * `HTTPIP` and `HTTPPort` - The IP and port, respectively of an HTTP server diff --git a/examples/README.md b/examples/README.md index b0d3b61..35173d6 100644 --- a/examples/README.md +++ b/examples/README.md @@ -2,7 +2,7 @@ In order for new users to get up and running with the packer builder, a few examples of building a machine image with popular distros have been created. At the time of this writing there are examples for the latest Ubuntu (20.04) and Centos (8.3) releases. Please open an issue if you'd like to see an example for another distro. -In order to see an exhaustive list of configuration options for the packer builder please see the [following documentation](docs/builders/xenserver-iso.html.markdown). This doc will focus on the details relevant to the particular distro. +In order to see an exhaustive list of configuration options for the packer builder please see the [following documentation](../docs/builders/xenserver-iso.html.markdown). This doc will focus on the details relevant to the particular distro. ### Running the examples @@ -23,11 +23,11 @@ packer build -debug --var sr_name='Local storage' --var sr_iso_name=LocalISO ex The Ubuntu example uses the [autoinstall tool](https://ubuntu.com/server/docs/install/autoinstallhttps://ubuntu.com/server/docs/install/autoinstall) to configure the VM template. Please see the [autoinstall docs](https://ubuntu.com/server/docs/install/autoinstall-reference) for an exhaustive list of what is supported. -Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [user-data](examples/http/ubuntu-2004/user-data) and [meta-data](examples/http/ubuntu-2004/meta-data) for autoinstall must be present. +Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [user-data](http/ubuntu-2004/user-data) and [meta-data](http/ubuntu-2004/meta-data) for autoinstall must be present. ### Centos The centos example uses kickstart to configure the VM template. Please see the [kickstart documentation](https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/installation_guide/sect-kickstart-syntax) for the options that are supported. -Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [kickstart config](examples/http/centos8/ks-centos8.cfg) file must be present. +Packer will create a http server to serve the files as specified from the `http_directory` specified in the builder configuration. This is where the [kickstart config](http/centos8/ks-centos8.cfg) file must be present. From 4869b524d8aea3592f8810f5ff5abb82705560d7 Mon Sep 17 00:00:00 2001 From: Dom Del Nano Date: Sun, 3 Jan 2021 00:00:06 -0800 Subject: [PATCH 6/6] Remove unnecesary step --- examples/README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/examples/README.md b/examples/README.md index 35173d6..60f7d32 100644 --- a/examples/README.md +++ b/examples/README.md @@ -7,9 +7,8 @@ In order to see an exhaustive list of configuration options for the packer build ### Running the examples In order to run this example you will need to perform the following steps: -1. Ensure that you are running packer from a machine on the same subnet as the VM packer will be launching. This can be overriden with the `network_names` builder configuration if needed. -2. Export the `XAPI_HOST`, `XAPI_USERNAME` and `XAPI_PASSWORD` environment variables to the current shell. Note: The `XAPI_HOST` must be the resource pool primary. -3. Run the `packer build` command specifying the storage repositories to use for the ISO upload and for the VM created during the build. +1. Export the `XAPI_HOST`, `XAPI_USERNAME` and `XAPI_PASSWORD` environment variables to the current shell. Note: The `XAPI_HOST` must be the resource pool primary. +2. Run the `packer build` command specifying the storage repositories to use for the ISO upload and for the VM created during the build. ``` # Replace sr_name and sr_iso_name with your storage repositories names