Initial check-in for repo structure

This commit is contained in:
Jeffrey Cline
2018-01-30 13:53:31 -08:00
parent a44d015aa3
commit 0ba5c18031
6 changed files with 553 additions and 3 deletions

View File

@ -0,0 +1,19 @@
#
#
# Provider and credential snippet to add to configurations
# Assumes that there's a terraform.tfvars file with the var values
#
# Uncomment the creds variables if using service principal auth
# Leave them commented to use MSI auth
#
#variable subscription_id {}
#variable tenant_id {}
#variable client_id {}
#variable client_secret {}
provider "azurerm" {
# subscription_id = "${var.subscription_id}"
# tenant_id = "${var.tenant_id}"
# client_id = "${var.client_id}"
# client_secret = "${var.client_secret}"
}

View File

@ -0,0 +1,56 @@
#!/bin/bash
logger -t devvm "Desktop Install started: $?"
sudo apt-get -y update
sudo apt-get -q=2 -y install xrdp
logger -t devvm "XRDP installed: $?"
logger -t devvm "Installing Mate Desktop ..."
sudo dpkg --configure -a
sudo apt-add-repository -y ppa:ubuntu-mate-dev/ppa
sudo apt-add-repository -y ppa:ubuntu-mate-dev/trusty-mate
sudo apt-get -y update
sudo apt-get -y upgrade
sudo apt-get install -q=2 --no-install-recommends -m ubuntu-mate-core
sudo apt-get install -q=2 --no-install-recommends -m ubuntu-mate-desktop
logger -t devvm "Mate Desktop installed. $?"
echo mate-session >~/.xsession
sudo service xrdp restart
# FIxes the issue with Ubuntu desktop being blank.
sudo sed -i -e 's/console/anybody/g' /etc/X11/Xwrapper.config
logger -t devvm "Mate Desktop configured. $?"
logger -t devvm "Installing VSCode: $?"
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg
sudo mv microsoft.gpg /etc/apt/trusted.gpg.d/microsoft.gpg
sudo sh -c 'echo "deb [arch=amd64] https://packages.microsoft.com/repos/vscode stable main" > /etc/apt/sources.list.d/vscode.list'
sudo apt-get update
sudo apt-get install -y code
logger -t devvm "VSCode Installed: $?"
logger -t devvm "Success"
exit 0

View File

@ -0,0 +1,19 @@
#!/bin/bash
apt-get update
wget -O terraform.zip https://releases.hashicorp.com/terraform/0.11.1/terraform_0.11.1_linux_amd64.zip?_ga=2.228206621.1801000149.1512425211-1345627201.1504718143
apt-get install unzip
unzip terraform.zip
mv terraform /usr/local/bin
echo "deb [arch=amd64] https://packages.microsoft.com/repos/azure-cli/ wheezy main" | sudo tee /etc/apt/sources.list.d/azure-cli.list
apt-key adv --keyserver packages.microsoft.com --recv-keys 52E16F86FEE04B979B07E28DB02C46DF417A0893
apt-get install apt-transport-https
apt-get update && sudo apt-get install azure-cli

View File

@ -0,0 +1,132 @@
#!/bin/bash
# Script Name: install.sh
# Author: Greg Oliver - Microsoft github:(sebastus)
# Version: 0.1
# Last Modified By: Greg Oliver
# Description:
# This script configures authentication for Terraform and remote state for Terraform.
# Parameters :
# 1 - s: Azure subscription ID
# 2 - a: Storage account name
# 3 - k: Storage account key (password)
# 4 - l: MSI client id (principal id)
# 5 - u: User account name
# 6 - d: Ubuntu Desktop GUI for developement
# 7 - h: help
# Note :
# This script has only been tested on Ubuntu 12.04 LTS & 14.04 LTS and must be root
set -e
logger -t devvm "Install started: $?"
help()
{
echo "This script sets up a node, and configures pre-installed Splunk Enterprise"
echo "Usage: "
echo "Parameters:"
echo "- s: Azure subscription ID"
echo "- a: Storage account name"
echo "- k: Storage account key (password)"
echo "- l: MSI client id (principal id)"
echo "- u: User account name"
echo "- d: Ubuntu Desktop GUI"
echo "- h: help"
}
# Log method to control log output
log()
{
echo "`date`: $1"
}
# You must be root to run this script
if [ "${UID}" -ne 0 ];
then
log "Script executed without root permissions"
echo "You must be root to run this program." >&2
exit 3
fi
# Arguments
while getopts :s:a:k:l:u:d: optname; do
if [[ $optname != 'e' && $optname != 'k' ]]; then
log "Option $optname set with value ${OPTARG}"
fi
case $optname in
s) #azure subscription id
SUBSCRIPTION_ID=${OPTARG}
;;
a) #storage account name
STORAGE_ACCOUNT_NAME=${OPTARG}
;;
k) #storage account key
STORAGE_ACCOUNT_KEY=${OPTARG}
;;
l) #PrincipalId of the MSI identity
MSI_PRINCIPAL_ID=${OPTARG}
;;
u) #user account name
USERNAME=${OPTARG}
;;
d) #Desktop installation
DESKTOPINSTALL=${OPTARG}
;;
h) #Show help
help
exit 2
;;
\?) #Unrecognized option - show help
echo -e \\n"Option -${BOLD}$OPTARG${NORM} not allowed."
help
exit 2
;;
esac
done
TEMPLATEFOLDER="/home/$USERNAME/tfTemplate"
REMOTESTATEFILE="$TEMPLATEFOLDER/remoteState.tf"
ACCESSKEYFILE="/home/$USERNAME/access_key"
TFENVFILE="/home/$USERNAME/tfEnv.sh"
CREDSFILE="$TEMPLATEFOLDER/azureProviderAndCreds.tf"
mkdir $TEMPLATEFOLDER
cp ./azureProviderAndCreds.tf $TEMPLATEFOLDER
chmod 666 $CREDSFILE
touch $REMOTESTATEFILE
echo "terraform {" >> $REMOTESTATEFILE
echo " backend \"azurerm\" {" >> $REMOTESTATEFILE
echo " storage_account_name = \"$STORAGE_ACCOUNT_NAME\"" >> $REMOTESTATEFILE
echo " container_name = \"terraform-state\"" >> $REMOTESTATEFILE
echo " key = \"prod.terraform.tfstate\"" >> $REMOTESTATEFILE
echo " }" >> $REMOTESTATEFILE
echo "}" >> $REMOTESTATEFILE
chmod 666 $REMOTESTATEFILE
chown -R $USERNAME:$USERNAME /home/$USERNAME/tfTemplate
touch $ACCESSKEYFILE
echo "access_key = \"$STORAGE_ACCOUNT_KEY\"" >> $ACCESSKEYFILE
chmod 666 $ACCESSKEYFILE
chown $USERNAME:$USERNAME $ACCESSKEYFILE
touch $TFENVFILE
echo "export ARM_SUBSCRIPTION_ID =\"$SUBSCRIPTION_ID\"" >> $TFENVFILE
echo "export ARM_CLIENT_ID =\"$MSI_PRINCIPAL_ID\"" >> $TFENVFILE
chmod 755 $TFENVFILE
chown $USERNAME:$USERNAME $TFENVFILE
# create the container for remote state
logger -t devvm "Creating the container for remote state"
az login --msi
az storage container create -n terraform-state --account-name $STORAGE_ACCOUNT_NAME --account-key $STORAGE_ACCOUNT_KEY
logger -t devvm "Container for remote state created: $?"
if [[ -v DESKTOPINSTALL ]]; then
echo "Installing Mate Desktop"
bash ./desktop.sh
echo "Desktop installed"
fi