You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
697 B
30 lines
697 B
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
if [ ! -f .ssh/id_ed25519.pub ]; then
|
|
echo "Generating new ssh key pair..."
|
|
ssh-keygen -t ed25519 -f .ssh/id_ed25519 -N ""
|
|
fi
|
|
|
|
echo "Installing dependencies..."
|
|
ansible-galaxy install -r requirements.yml
|
|
|
|
new_ip_addr=true
|
|
if [ -f inventory ]; then
|
|
current_ip_addr=$(cat inventory | awk 'NR==2')
|
|
read -p "Target ip is $current_ip_addr, do you want to change it? (y/N): " res
|
|
[[ $res =~ [Yy] ]] || new_ip_addr=false
|
|
fi
|
|
|
|
echo $new_ip_addr
|
|
|
|
if [ $new_ip_addr ]; then
|
|
read -p "Target ip address: " ip_addr
|
|
echo "[all]" > inventory
|
|
echo $ip_addr >> inventory
|
|
fi
|
|
|
|
exit 1
|
|
|
|
echo "Running playbook, this may take 5 to 10 minutes..."
|
|
ansible-playbook main.yml -k
|
|
|