Skip to content

Commit

Permalink
Merge pull request #24 from sbates130272/dev/packages
Browse files Browse the repository at this point in the history
virt-install-ubuntu: Add an option to include package install
  • Loading branch information
sbates130272 committed Nov 12, 2022
2 parents c76b818 + f4d8874 commit 2684373
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 2 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ scripts/initramfs.cpio.gz
scripts/image.img
scripts/rootfs
libvirt/hostname.tmp
libvirt/focal-*.img
libvirt/jammy-*.img
*~
16 changes: 16 additions & 0 deletions libvirt/packages.d/packages-default
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# packages-default: My default list of initial packages.
# Note indent by 2 spaces and use a hyphen!
- bmon
- build-essential
- emacs-nox
- fio
- git
- gnuplot
- gpg-agent
- libaio-dev
- liburing-dev
- python2
- python3-pip
- mutt
- sysstat
- tree
6 changes: 6 additions & 0 deletions libvirt/packages.d/packages-minimal
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# packages-default: My minimal list of initial packages
# Note indent by 2 spaces and use a hyphen!
- emacs-nox
- fio
- sysstat
- tree
22 changes: 20 additions & 2 deletions libvirt/virt-install-ubuntu
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,12 @@
# Note that after running this script you might want to remove the
# cloud-init disk from the VM. See [1] for info on how to do that.

# Note that the variables ARCH, SSH_KEY_FILE, USERNAME, PASS and
# NOAUTOCONSOLE only apply to focal or later.
# Note that the variables ARCH, SSH_KEY_FILE, USERNAME, PASS,
# NOAUTOCONSOLE and PACKAGES only apply to focal or later.
#
# PACKAGES is a file of packages to be installed via cloud-init. A
# couple of my favourite collections can be found in the packages.d
# folder.

NAME=${NAME:-qemu-minimal}
KS=${KS:-none}
Expand All @@ -62,6 +66,7 @@ SSH_KEY_FILE=${SSH_KEY_FILE:-~/.ssh/id_rsa.pub}
NOAUTOCONSOLE=${NOAUTOCONSOLE:-false}
USERNAME=${USERNAME:-ubuntu}
PASS=${PASS:-password}
PACKAGES=${PACKAGES:-none}

if [ $RELEASE == "bionic" ]; then

Expand Down Expand Up @@ -134,6 +139,17 @@ if [ ! -f $SSH_KEY_FILE ]; then
exit 1
fi

if [ ${PACKAGES} != "none" ]; then
if [ -f ${PACKAGES} ]; then
PACKAGES=$(<${PACKAGES})
else
echo "Package manifest file ${PACKAGES} does not exist!"
exit 1
fi
else
PACKAGES=
fi

cat << EOF > cloud-config-${NAME}
#cloud-config
hostname: ${NAME}
Expand All @@ -148,6 +164,8 @@ users:
shell: /bin/bash
ssh_authorized_keys: |
$(sed -z 's|\n|\n |g' ${SSH_KEY_FILE})
packages:
${PACKAGES}
power_state:
delay: now
mode: poweroff
Expand Down

0 comments on commit 2684373

Please sign in to comment.