summaryrefslogtreecommitdiff
path: root/ansible/setup_dev_machine.sh
diff options
context:
space:
mode:
authorSrdjan Grubor <sgnn7@sgnn7.org>2014-01-14 15:11:36 -0600
committerSrdjan Grubor <sgnn7@sgnn7.org>2014-01-16 21:46:33 -0600
commit5214ed7a373ef9bea7c2028cbe60e264449da812 (patch)
tree5b1a5a0a0516824a816b96f7d1b3e650b77c3118 /ansible/setup_dev_machine.sh
parenta70540d2e6bff081f8d97686320597680960c799 (diff)
Initial addition of ansible scripts
Diffstat (limited to 'ansible/setup_dev_machine.sh')
-rwxr-xr-xansible/setup_dev_machine.sh40
1 files changed, 40 insertions, 0 deletions
diff --git a/ansible/setup_dev_machine.sh b/ansible/setup_dev_machine.sh
new file mode 100755
index 0000000..9387570
--- /dev/null
+++ b/ansible/setup_dev_machine.sh
@@ -0,0 +1,40 @@
+#!/bin/bash -e
+
+#DEFAULT_USER="endless"
+DEFAULT_USER="sg"
+DEFAULT_PASSWORD="endless"
+DEFAULT_IP="192.168.56.101"
+
+echo "To run this script, you need to have the following"
+echo " - VM running with the correct dev HD image"
+echo " - A user defined with sudo privileges"
+echo " - sshpass installed on the local machine"
+echo
+read -p "Press [Enter] to continue..."
+
+if [[ ! $(which sshpass) ]]; then
+ echo "sshpass not found. Exiting"
+ echo "You can install it with sudo apt-get install sshpass"
+ exit 1
+fi
+
+read -e -p "Enter your machine's IP: " -i "$DEFAULT_IP" TARGET_IP
+read -e -p "Enter your machine's user: " -i "$DEFAULT_USER" TARGET_USER
+read -e -p "Enter your machine's password: " -i "${DEFAULT_PASSWORD}" TARGET_PASS
+echo
+
+echo -n "Checking connectivity to machine..."
+sshpass -p "${TARGET_PASS}" ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no $TARGET_USER@$TARGET_IP 'uname -a' &> /dev/null
+echo "[OK]"
+echo
+
+tmp_inventory=$(mktemp)
+trap "rm -f $tmp_inventory" EXIT
+
+echo "Creating Ansible inventory file in $tmp_inventory"
+cat << EOF > $tmp_inventory
+[dev_machine]
+dev_machine ansible_ssh_host=$TARGET_IP ansible_ssh_user="$TARGET_USER" ansible_ssh_pass="${TARGET_PASS}" ansible_connection=ssh
+EOF
+
+ansible-playbook -i $tmp_inventory playbooks/setup_dev_machine.yaml