infra-as-code/self_service.sh

26 lines
604 B
Bash
Executable File

#!/usr/bin/env bash
copy_template() {
cp -f ../../templates/$1 ./$2
}
read -p "Klantnaam: " customerName
mkdir -p ./customers/$customerName && cd $_
read -p "Ip: " ipAddr
echo -e "[nginx]\n$ipAddr" > ./inventory
copy_template ./Vagrantfile.template ./Vagrantfile
sed -i "s/#{customerName}/$customerName/" ./Vagrantfile
sed -i "s/#{ipAddr}/$ipAddr/" ./Vagrantfile
copy_template ./ansible.cfg.template ./ansible.cfg
mkdir -p ./.ssh/
ssh-keygen -t rsa -b 2048 -f ./.ssh/id_rsa
vagrant up
ansible all -m ping
ansible-playbook --ask-become-pass ./../../playbooks/install_nginx.yml
firefox $ipAddr