Debian cloud-init userdata

When you spin up a cloud VM at Google Compute or Digital Ocean there’s an option to specify user data, this is my goto script to update Debian and setup a  2G swapfile.

#!/usr/bin/env bash
dd if=/dev/zero of=/swap bs=1M count=2048
chmod 600 /swap
mkswap /swap
swapon /swap
echo "/swap swap swap defaults 0 0" >> /etc/fstab
apt update
apt -y upgrade
shutdown -r now

Debian userdata bootstrap

apt-get update && apt-get -y upgrade && dd if=/dev/zero of=/swap bs=1M count=2048 && chmod 600 /swap && mkswap /swap && swapon /swap && echo "/swap swap swap defaults 0 0" >> /etc/fstab && apt-get -y install salt-minion git rsync && echo "master: orchestration.mindlogic.io" >> /etc/salt/minion && systemctl enable salt-minion && shutdown -r now