Skip to content

Instantly share code, notes, and snippets.

@mark-rushakoff
Last active August 9, 2022 17:45
Show Gist options
  • Save mark-rushakoff/6f5f09ce9f3a7da792582d0fbbcb98a1 to your computer and use it in GitHub Desktop.
Save mark-rushakoff/6f5f09ce9f3a7da792582d0fbbcb98a1 to your computer and use it in GitHub Desktop.
{
"builders": [
{
"type": "qemu",
"iso_url": "http://cloud-images.ubuntu.com/releases/bionic/release/ubuntu-18.04-server-cloudimg-amd64.img",
"iso_checksum_url": "http://cloud-images.ubuntu.com/releases/bionic/release/SHA256SUMS",
"iso_checksum_type": "sha256",
"disk_image": true,
"disk_size": 5120,
"disk_interface": "virtio-scsi",
"disk_discard": "unmap",
"ssh_username": "packer",
"ssh_password": "packerpassword",
"http_directory": "cloud-data",
"qemuargs": [
["-smbios", "type=1,serial=ds=nocloud-net;instance-id=packer;seedfrom=http://{{ .HTTPIP }}:{{ .HTTPPort }}/"]
],
"use_default_display": true
}
],
"provisioners": [
{
"type": "shell",
"inline": ["echo Your steps go here."]
},
{
"type": "shell",
"execute_command": "sudo sh -c '{{ .Vars }} {{ .Path }}'",
"remote_folder": "/tmp",
"inline": [
"/usr/bin/apt-get clean",
"rm -r /etc/apparmor.d/cache/* /etc/apparmor.d/cache/.features /etc/netplan/50-cloud-init.yaml /etc/ssh/ssh_host* /etc/sudoers.d/90-cloud-init-users",
"/usr/bin/truncate --size 0 /etc/machine-id",
"/usr/bin/gawk -i inplace '/PasswordAuthentication/ { gsub(/yes/, \"no\") }; { print }' /etc/ssh/sshd_config",
"rm -r /root/.ssh",
"rm /snap/README",
"find /usr/share/netplan -name __pycache__ -exec rm -r {} +",
"rm /var/cache/pollinate/seeded /var/cache/snapd/* /var/cache/motd-news",
"rm -r /var/lib/cloud /var/lib/dbus/machine-id /var/lib/private /var/lib/systemd/timers /var/lib/systemd/timesync /var/lib/systemd/random-seed",
"rm /var/lib/ubuntu-release-upgrader/release-upgrade-available",
"rm /var/lib/update-notifier/fsck-at-reboot /var/lib/update-notifier/hwe-eol",
"find /var/log -type f -exec rm {} +",
"rm -r /tmp/* /tmp/.*-unix /var/tmp/*",
"for i in group gshadow passwd shadow subuid subgid; do mv /etc/$i- /etc/$i; done",
"rm -r /home/packer",
"/bin/sync",
"/sbin/fstrim -v /"
]
}
]
}
#cloud-config
ssh_pwauth: true
users:
- name: packer
sudo: ALL=(ALL) NOPASSWD:ALL
groups: users, admin
passwd: $6$rounds=4096$XxQGokSw4FI8unZF$lAnQ0ZSMuCvSlv.rFjcxOpyAZr/ZDwtaI/X6BSSH0wtKngvprmgr9nvSMV/dBzE.TJ7Tvd8y0.T50dW5Bi1vf/
lock_passwd: false
apt:
preserve_sources_list: true
package_update: false
@mark-rushakoff
Copy link
Author

The pastebin link in the title is from https://multipass.run/docs/building-multipass-images-with-packer, but you had to log in to view it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment