Skip to content

Instantly share code, notes, and snippets.

@alghanmi
Last active April 8, 2018 01:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alghanmi/e17d5c901a695901ce54a5194051f7c7 to your computer and use it in GitHub Desktop.
Save alghanmi/e17d5c901a695901ce54a5194051f7c7 to your computer and use it in GitHub Desktop.
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
Copy link
Author

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