#!/bin/bash
dir=$(dirname $0)

echo -e "\033[32m>>>>部署ansible\033[0m"
${dir}/shell/install-ansible.sh
${dir}/shell/keepalived_vrid.sh
sed -i "s/\(virtual_router_id\)\ \(.*\)/\1 $(cat /tmp/keepalived.vrid)/" ${dir}/ansible/roles/04*/templates/*.j2

\cp ${dir}/config ${dir}/ansible/hosts/hosts

ansible-playbook -i ${dir}/ansible/hosts/hosts ${dir}/ansible/04* --tags=install --become  --become-method=sudo --become-user=root
ansible-playbook -i ${dir}/ansible/hosts/hosts ${dir}/ansible/03* --tags=install --become  --become-method=sudo --become-user=root
ansible-playbook -i ${dir}/ansible/hosts/hosts ${dir}/ansible/05*                --become  --become-method=sudo --become-user=root
ansible-playbook -i ${dir}/ansible/hosts/hosts ${dir}/ansible/06*                --become  --become-method=sudo --become-user=root
