infra/roles/mainframe/templates/tf-convergence.sh.j2

32 lines
774 B
Django/Jinja

#!/bin/bash
set -e
LOCKFILE=/tmp/tf-convergence.lock
/usr/bin/lockfile -r 0 $LOCKFILE
{% set base = git_cron.base_path %}
{% set tools_path = "/var/www/" + git_cron.tools_url %}
(
cd {{ base }}/tf
./tf.py init &>> {{ base }}/convergence-tf.log
# pipe the output to a tmp file, filter it, throw away temp file
./tf.py plan &> {{ base }}/convergence-tf.tmp
set +e
/usr/bin/egrep "\~|\+ resource|\- resource" {{ base }}/convergence-tf.tmp > {{ base }}/convergence-tf.txt
set -e
/usr/bin/cp {{ base }}/convergence-tf.txt {{ tools_path }}/convergence/convergence-tf.txt
# log it
/usr/bin/cat {{ base }}/convergence-tf.tmp >> {{ base }}/convergence-tf.log
/usr/bin/rm {{ base }}/convergence-tf.tmp
)
/usr/bin/rm -f $LOCKFILE