Merge "Remove unused EnablePacemaker param from templates"
[apex-tripleo-heat-templates.git] / extraconfig / tasks / yum_update.sh
1 #!/bin/bash
2
3 # A heat-config-script which runs yum update during a stack-update.
4 # Inputs:
5 #   deploy_action - yum will only be run if this is UPDATE
6 #   update_identifier - yum will only run for previously unused values of update_identifier
7 #   command - yum sub-command to run, defaults to "update"
8 #   command_arguments - yum command arguments, defaults to ""
9
10 echo "Started yum_update.sh on server $deploy_server_id at `date`"
11
12 if [[ -z "$update_identifier" ]]; then
13     echo "Not running due to unset update_identifier"
14     exit 0
15 fi
16
17 timestamp_dir=/var/lib/overcloud-yum-update
18 mkdir -p $timestamp_dir
19
20 # sanitise to remove unusual characters
21 update_identifier=${update_identifier//[^a-zA-Z0-9-_]/}
22
23 timestamp_file="$timestamp_dir/$update_identifier"
24 if [[ -a "$timestamp_file" ]]; then
25     echo "Not running for already-run timestamp \"$update_identifier\""
26     exit 0
27 fi
28 touch "$timestamp_file"
29
30 command=${command:-update}
31 full_command="yum -y $command $command_arguments"
32 echo "Running: $full_command"
33
34 result=$($full_command)
35 return_code=$?
36 echo "$result"
37 echo "yum return code: $return_code"
38
39 echo "Finished yum_update.sh on server $deploy_server_id at `date`"
40
41 exit $return_code