summaryrefslogtreecommitdiff
path: root/install.sh
blob: e329856bde93812b6e89cd0499a25f6956f1ff38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash

if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
  echo "$0 <hostname> <distro> <codename>"
  exit 1
fi
name=$1
distro=$2
codename=$3
shift 3

cd "${BASH_SOURCE%/*}"
source common/utils.sh
ansible_variable__get env_group "$name" || exit 1
vault_environment__set "$env_group" || exit 1

echo "installing $name with $distro/$codename in environment '$env_group'"
echo ""

echo "########## clearing old ssh host keys #########"
./remove-known-host.sh "$name"
echo ""

echo "########## removing cached facts #########"
rm -f ".cache/facts/$name"
echo ""

echo "######## running the install playbook ########"
exec ansible-playbook -e "install_hostname=$name" -e "install_distro=$distro" -e "install_codename=$codename" -e "install_environment=$env_group" $@ "$env_group/$(basename "$0" .sh).yml"