Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Prepare a Debian VPS for Ansible Run
#!/bin/bash
if [[ $EUID -ne 0 ]]; then
echo "This script must be run as root"
exit 1
fi
# 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 ""
else
adduser --disabled-password --gecos "$_NAME,,," $_USER
#Set user password
echo -n "Enter User Password: "
read -s _PASS
echo "$_USER:$_PASS" | chpasswd
unset _PASS
fi
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 ""
@alghanmi

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 - https://gist.githubusercontent.com/alghanmi/e17d5c901a695901ce54a5194051f7c7/raw/vps_prep.sh | 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.