Merge "Add validation for VPP upgrade tasks"
[apex-tripleo-heat-templates.git] / extraconfig / tasks / tripleo_upgrade_node.sh
1 #!/bin/bash
2 #
3 # This delivers the operator driven upgrade script to be invoked as part of
4 # the tripleo major upgrade workflow. The utility 'upgrade-non-controller.sh'
5 # is used from the undercloud to invoke the /root/tripleo_upgrade_node.sh
6 #
7 set -eu
8
9 UPGRADE_SCRIPT=/root/tripleo_upgrade_node.sh
10
11 cat > $UPGRADE_SCRIPT << ENDOFCAT
12 ### DO NOT MODIFY THIS FILE
13 ### This file is automatically delivered to those nodes where the
14 ### disable_upgrade_deployment flag is set in roles_data.yaml.
15
16 set -eu
17 NOVA_COMPUTE=""
18 if hiera -c /etc/puppet/hiera.yaml service_names | grep nova_compute ; then
19    NOVA_COMPUTE="true"
20 fi
21 SWIFT_STORAGE=""
22 if hiera -c /etc/puppet/hiera.yaml service_names | grep swift_storage ; then
23    SWIFT_STORAGE="true"
24 fi
25
26 DEBUG="true"
27 SCRIPT_NAME=$(basename $0)
28 $(declare -f log_debug)
29 $(declare -f manage_systemd_service)
30 $(declare -f systemctl_swift)
31
32 # pin nova messaging +-1 for the nova-compute service
33 if [[ -n \$NOVA_COMPUTE ]]; then
34     crudini  --set /etc/nova/nova.conf upgrade_levels compute auto
35 fi
36
37 if [[ -n \$SWIFT_STORAGE ]]; then
38     systemctl_swift stop
39 fi
40
41 yum -y update
42
43 if [[ -n \$SWIFT_STORAGE ]]; then
44     systemctl_swift start
45 fi
46 # Due to bug#1640177 we need to restart compute agent
47 if [[ -n \$NOVA_COMPUTE ]]; then
48     log_debug "Restarting openstack ceilometer agent compute"
49     systemctl restart openstack-ceilometer-compute
50 fi
51
52 # Apply puppet manifest to converge just right after the ${ROLE} upgrade
53 $(declare -f run_puppet)
54 for step in 1 2 3 4 5 6; do
55     log_debug "Running puppet step \$step for ${ROLE}"
56     if ! run_puppet /root/${ROLE}_puppet_config.pp ${ROLE} \${step}; then
57          log_debug "Puppet failure at step \${step}"
58          exit 1
59     fi
60     log_debug "Completed puppet step \$step"
61 done
62
63 log_debug "TripleO upgrade run completed."
64
65 ENDOFCAT
66
67 # ensure the permissions are OK
68 chmod 0755 $UPGRADE_SCRIPT
69