16584254073e4918e55295cd96a7e969f1a94079
[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 systemctl show 'openstack-nova-compute' --property ActiveState | grep '\bactive\b'; then
19    NOVA_COMPUTE="true"
20 fi
21
22 DEBUG="true"
23 SCRIPT_NAME=$(basename $0)
24 $(declare -f log_debug)
25 $(declare -f manage_systemd_service)
26 $(declare -f systemctl_swift)
27
28 # pin nova messaging +-1 for the nova-compute service
29 if [[ -n \$NOVA_COMPUTE ]]; then
30     crudini  --set /etc/nova/nova.conf upgrade_levels compute auto
31 fi
32
33 $(declare -f special_case_ovs_upgrade_if_needed)
34 special_case_ovs_upgrade_if_needed
35
36 yum -y install python-zaqarclient  # needed for os-collect-config
37 systemctl_swift stop
38 yum -y update
39 systemctl_swift start
40
41 # Due to bug#1640177 we need to restart compute agent
42 if [[ -n \$NOVA_COMPUTE ]]; then
43     echo "Restarting openstack ceilometer agent compute"
44     systemctl restart openstack-ceilometer-compute
45 fi
46
47 # Apply puppet manifest to converge just right after the ${ROLE} upgrade
48 $(declare -f run_puppet)
49 for step in 1 2 3 4 5 6; do
50     if ! run_puppet /root/${ROLE}_puppet_config.pp ${ROLE} \${step}; then
51          echo "Puppet failure at step \${step}"
52          exit 1
53     fi
54 done
55 ENDOFCAT
56
57 # ensure the permissions are OK
58 chmod 0755 $UPGRADE_SCRIPT
59