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

48 lines
919 B
Bash
Raw Normal View History

2017-08-31 21:22:57 +02:00
#!/usr/bin/env bash
prereqs="curl wget ansible"
2020-04-26 15:37:31 +02:00
remote_file_url="https://git.paulbsd.com/paulbsd/ansible-gnu-corporate-workstation/archive/master.zip"
2017-08-31 23:43:52 +02:00
tmp_dir="/tmp"
2020-04-26 15:46:26 +02:00
archive_file="/tmp/ansible-gnu-corporate-workstation-master.zip"
working_directory="/tmp/ansible-gnu-corporate-workstation"
2020-04-26 16:41:22 +02:00
playbook_file="playbook.yml"
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}
2020-04-26 16:41:22 +02:00
unzip -o -d ${tmp_dir} ${archive_file}
2017-08-31 21:22:57 +02:00
}
run_playbook()
{
2017-08-31 23:43:52 +02:00
cd ${working_directory}
2020-04-26 16:41:22 +02:00
sudo ansible-playbook -i hosts ${playbook_file}
2017-08-31 23:43:52 +02:00
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 ..."
2020-04-26 16:41:22 +02:00
run_playbook && cleanup
2017-08-31 21:22:57 +02:00
fi