ansible-gnu-corporate-works.../provision.sh

47 lines
869 B
Bash
Raw Normal View History

2017-08-31 21:22:57 +02:00
#!/usr/bin/env bash
prereqs="curl wget ansible"
remote_file_url="https://github.com/paulbsd/ansible-gnu-corporate-workstation/archive/master.zip"
2017-08-31 23:43:52 +02:00
tmp_dir="/tmp"
archive_file="/tmp/master.zip"
2017-08-31 23:43:52 +02:00
working_directory="/tmp/ansible-gnu-corporate-workstation-master"
2017-08-31 21:22:57 +02:00
update()
{
sudo apt-get update
sudo apt-get install -y ${prereqs}
2017-08-31 21:22:57 +02:00
}
fetch_archive()
{
wget -O ${archive_file} ${remote_file_url}
2017-08-31 23:43:52 +02:00
unzip -o -d /tmp /tmp/master.zip
2017-08-31 21:22:57 +02:00
}
run_playbook()
{
2017-08-31 23:43:52 +02:00
cd ${working_directory}
sudo ansible-playbook -i hosts playbook.yml
cd ${tmp_dir}
2017-08-31 21:22:57 +02:00
}
cleanup()
{
rm -rf ${archive_file}
rm -rf ${working_directory}
2017-08-31 21:22:57 +02:00
}
echo "Let's update repositories and install Ansible ..."
2017-08-31 21:22:57 +02:00
update
echo "Let's download archive ..."
fetch_archive
2017-08-31 23:43:52 +02:00
echo "Let's extract the archive ..."
2017-08-31 21:22:57 +02:00
if [[ -f ${archive_file} ]]
then
2017-08-31 23:43:52 +02:00
echo "Let's go ..."
run_playbook ${working_directory} && cleanup
2017-08-31 21:22:57 +02:00
fi