2018-05-28 03:01:28 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script will bootstrap the machine using Ansible
|
|
|
|
# Copyright (C) 2018 Elijah Lazkani
|
|
|
|
|
|
|
|
playbook=$1
|
|
|
|
|
|
|
|
function _find_ansible() {
|
|
|
|
|
|
|
|
command ansible-playbook -h > /dev/null 2>&1
|
|
|
|
if [[ $? -ne 0 ]];
|
|
|
|
then
|
|
|
|
echo "Ansible not found..."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
function _ansible () {
|
|
|
|
|
|
|
|
_find_ansible
|
|
|
|
|
|
|
|
echo "Bootstrapping Ansible"
|
|
|
|
if [[ $playbook ]];
|
|
|
|
then
|
2018-05-28 03:02:05 +00:00
|
|
|
if [ ! -f inventory.yml ];
|
2018-05-28 03:01:28 +00:00
|
|
|
then
|
|
|
|
echo "Inventory file not found"
|
2018-05-28 03:02:05 +00:00
|
|
|
exit 1
|
2018-05-28 03:01:28 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
echo "Sit down, relax and kick your legs up, fun is about to begin..."
|
2018-05-28 03:02:05 +00:00
|
|
|
ansible-playbook -i inventory.yml -c local Ansible/$playbook --ask-sudo-pass
|
2018-05-28 03:01:28 +00:00
|
|
|
else
|
|
|
|
echo "Choose a profile to run from the list below:"
|
|
|
|
find Ansible/ -maxdepth 1 -name "*.yml" -type f -printf " - %f\n"
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
_ansible
|