summaryrefslogtreecommitdiff
path: root/leap-deploy-node.sh
blob: 6051604476f4b123a99d3b95a372dc01be7ce28a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/bin/sh

. /etc/leap/platform-test.cfg

vm=$1

LOG="$LOGDIR/deploy-$vm.log"
ERRLOG="$LOGDIR/deploy-$vm-`date +"%F-%H%M%S"`-error.log"

cd $PROVIDERDIR


# remove colors until #1751 is fixed
RMCOLORS='s/\x1B\[([0-9]{1,2}(;[0-9]{1,2})?)?[m|K]//g'

# we need to deploy with verbose level 2, and filter out unwanted stuff
# until puppet errors show up in verbose level 0 +1 (#1750)
FILTER_CLI='= read|= loading|= no change|   - executing| = executing| = applying| = ran git| = checking| = synching| = skipping file_path|   - rsync|   - hiera|   - cd /root/|   - rolling backexecuting'
FILTER_PUPPET='] notice: |   - Puppet apply complete.|] warning: Dynamic lookup|] warning: Scope\(Class'
FILTER_ALL="($FILTER_CLI|$FILTER_PUPPET)"


echo "Deploying \"$vm\" on `date`"|tee -a $LOG

leap $OPTS -v 2 deploy $vm 2>&1 |  sed -r "$RMCOLORS" | tee -a $LOG | egrep -v "$FILTER_ALL" > $ERRLOG


if [ $? -eq 0 ]
then
  msg="From: $MAIL_FROM\nTo: $MAIL_TO\nSubject: Deploy to \"$vm\" had errors !\n\n`cat $ERRLOG`"
  echo "Deploy to \"$vm\" on `date` had errors." | tee -a $LOG
  echo "Sending this mail:"
  echo
  cat $ERRLOG 
  
  printf "$msg" | sendmail -t

else
  echo "Deploy to $vm on `date` went fine."| tee -a $LOG
fi

echo