#!/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 if $new_ip_addr; then read -p "Target ip address: " ip_addr echo "[all]" > inventory echo $ip_addr >> inventory fi echo "Running playbook, this may take 5 to 10 minutes..." ansible-playbook main.yml -k