Skip to content

Instantly share code, notes, and snippets.

@versionsix
Created August 7, 2019 11:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save versionsix/78b7ed5032743fb9bb411dc87d5baccc to your computer and use it in GitHub Desktop.
Save versionsix/78b7ed5032743fb9bb411dc87d5baccc to your computer and use it in GitHub Desktop.
Legacy free openstack images
wget -O /var/lib/libvirt/images/ubuntu-bionic.qcow2 https://cloud-images.ubuntu.com/bionic/current/bionic-server-cloudimg-amd64.img
cat <<EOF > 51-vga.cfg
GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0 vga=789"
EOF
virt-copy-in -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 51-vga.cfg /etc/default/grub.d
virt-customize -v -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 \
--run-command "update-grub" \
--run-command "apt -yqq update && apt -yqq upgrade" \
--run-command "apt -y -qq --no-install-recommends install jq dnsutils && apt -y autoremove" \
--run-command "mkdir -p /etc/systemd/system/getty@tty1.service.d && mkdir -p /etc/systemd/system/serial-getty@ttyS0.service.d && mkdir -p /etc/cloud/cloud.cfg.d/"
cat <<EOF > override.conf
[Service]
Type=simple
ExecStart=
ExecStart=-/sbin/agetty --autologin root --noclear %I 38400 linux
EOF
virt-copy-in -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 override.conf /etc/systemd/system/getty@tty1.service.d
cat <<EOF > override.conf
[Service]
Type=simple
ExecStart=
ExecStart=-/sbin/agetty --autologin ubuntu --noclear %I 38400 linux
EOF
virt-copy-in -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 override.conf /etc/systemd/system/serial-getty@ttyS0.service.d
cat <<EOF > 98-openstack-network.cfg
datasource:
OpenStack:
apply_network_config: True
EOF
virt-copy-in -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 98-openstack-network.cfg /etc/cloud/cloud.cfg.d/
virt-sysprep -v -a /var/lib/libvirt/images/ubuntu-bionic.qcow2 \
--colors --operations machine-id
# virt-sparsify /var/lib/libvirt/images/ubuntu-bionic.qcow2 /usr/share/nginx/html/ubuntu-bionic.qcow2
qemu-img convert -O qcow2 -c /var/lib/libvirt/images/ubuntu-bionic.qcow2 /usr/share/nginx/html/ubuntu-bionic.qcow2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment