#!/usr/bin/env bash # Set pwd, don't expect to use cd /home/ansible # Ensure we have a log dir mkdir -p /home/ansible/logs cd /home/ansible/infra git fetch origin > /dev/null 2>&1 BEHIND_COUNT=$(git rev-list --count HEAD..@{u}) if [ "$BEHIND_COUNT" -gt 0 ]; then git pull else echo "Local branch is up to date with the remote, no changes." fi # Create a venv python3 -m venv /home/ansible/venv # Source venv . /home/ansible/venv/bin/activate # Install requirements for ansible pip install -r /home/ansible/infra/ansible/requirements.txt # Change into ansible subdir of repo cd /home/ansible/infra/ansible source /home/ansible/.bws # Run updates ansible-playbook site.yaml >> /home/ansible/logs/runner.log