Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Prepare a Debian VPS for Ansible Run
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
# Set User information
export _USER="rami"
export _NAME="Rami AlGhanmi"
# Update packages and install required packages
apt-get update
apt-get upgrade --yes
apt-get install --yes sudo apt-transport-https dirmngr python python-simplejson
# Create user if it does not exist
if id "$_USER" >/dev/null 2>&1; then
echo ""
adduser --disabled-password --gecos "$_NAME,,," $_USER
#Set user password
echo -n "Enter User Password: "
read -s _PASS
echo "$_USER:$_PASS" | chpasswd
unset _PASS
echo -e "$_USER\tALL = (ALL) NOPASSWD: ALL" >> /etc/sudoers.d/10-admin
chmod 440 /etc/sudoers.d/10-admin
# Cleanup Variables
unset _USER
unset _NAME
echo ""

This comment has been minimized.

Copy link
Owner Author

alghanmi commented Feb 27, 2017

This is to be used to bootstrap a VM for Ansible. This is for a minimal debian setup which only has wget installed and outdated certificate:

wget --no-check-certificate -O - | bash
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.