* Install Debian * Update and install necessary packages (or needed in template) ```bash apt update apt install open-vm-tools aptitude vim htop sudo -y apt upgrade -y ``` * Add user to sudo group (in my scenario used for ansible) ```bash usermod -aG sudo administrator ``` * Allow sudo without password ``` sed -i /etc/sudoers -re 's/^%sudo.*/%sudo ALL=(ALL:ALL) NOPASSWD: ALL/g' ``` * Cleanup VM for template ``` # cleanup current ssh keys so templated VMs get fresh key sudo rm -f /etc/ssh/ssh_host_* ``` ``` # add check for ssh keys on reboot...regenerate if neccessary tee /etc/rc.local >/dev/null </dev/null # disable swap swapoff --all sed -ri '/\sswap\s/s/^#?/#/' /etc/fstab # cleanup shell history and shutdown for templating history -c history -w shutdown -h now ``` * Mark VM as a Template * Test with Terraform