Last active
April 8, 2018 01:55
-
-
Save alghanmi/e17d5c901a695901ce54a5194051f7c7 to your computer and use it in GitHub Desktop.
Prepare a Debian VPS for Ansible Run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 "" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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