This repository has been archived by the owner on May 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
dx-upgrade.yml
163 lines (153 loc) · 5.53 KB
/
dx-upgrade.yml
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
---
type: update
version: 1.5.2
name: Jahia - Upgrade
logo: /images/jahia-logo-70x70.png
id: jahia-upgrade
description:
short: Jahia - Upgrade
mixins:
- jahia/jahia_actions.yml
- haproxy/haproxy_actions.yml
- utils/compare-versions.yml
onInstall:
## Globals definition
- cmd [proc]: |-
## [Upgrade] - 1/2
exit 0
- if ('${settings.rollingUpgrade.print()}' == ''):
setGlobals:
rollingUpgrade: false
- else:
setGlobals:
rollingUpgrade: ${settings.rollingUpgrade}
# By default we assume it is a (rolling) redeploy only
- setGlobals:
targetDockerTag: ${nodes.proc.first.version}
upgradeJahia: false
useExistingVolumes: true
# If a Jahia version/docker tag was passed as parameter
- if ('${settings.targetVersion.print()}' != ''):
- setGlobals:
targetDockerTag: ${settings.targetVersion}
# If it is a new version of Jahia
- if ('${globals.targetDockerTag}' != '${nodes.proc.first.version}'):
- setGlobals:
upgradeJahia: true
useExistingVolumes: false
- setVersionPropertiesValue
# As a reminder, when updating the value of a global variable inside an "if" block,
# the new value won't be taken in account if testing it inside a nested "if" block.
## Upgrades
- if (!${globals.rollingUpgrade}):
# In case of Jahia upgrade, all jahia nodes must be stopped first
- cmd [cp, proc]:
- service tomcat stop
user: root
- procUpgrade
- bulkCpUpgrade
- else:
- procUpgrade
- rollingCpUpgrade
## Post-actions
# Get the Jahia version, which could be different of the name of the docker image
# e.g.: docker image tag "7.3.3.0_PAAS-444"
- api [${nodes.proc.first.id}]: environment.control.GetNodeInfo
- setGlobals:
targetJahiaVersion: ${response.node.version}
- env.control.ApplyNodeGroupData[cp, proc]:
data:
productVersion: ${globals.targetJahiaVersion}
- env.control.AddContainerEnvVars[cp, proc]:
vars: {"DX_VERSION": "${globals.targetJahiaVersion}"}
actions:
procUpgrade:
- cmd [proc]:
- echo 'export JAHIA_UPGRADE="${globals.upgradeJahia}"' >> /etc/locale.conf
user: root
- api: environment.control.RedeployContainersByGroup
nodeGroup: proc
tag: ${globals.targetDockerTag}
useExistingVolumes: ${globals.useExistingVolumes}
skipReinstall: false
envName: ${env.envName}
# restore-module-state is not compatible with rolling upgrade
- if (!${globals.rollingUpgrade}):
- cmd [proc]: |-
if [ $(echo $DX_VERSION | sed 's/\.//g') -ge 7320 ]; then
rm -fr /data/digital-factory-data/bundles-deployed/*
sudo -u tomcat touch "/data/digital-factory-data/[persisted-bundles].dorestore"
echo "restore-module-state have been asked"
ls -l /data/digital-factory-data/*.dorestore
else
echo "Can't use restore-module-state here"
fi
user: root
- cmd [proc]: |-
if [[ "${globals.upgradeJahia}" == "true" ]]; then
touch /data/digital-factory-data/modules/*
service tomcat start
fi
sed '/JAHIA_UPGRADE/d' -i /etc/locale.conf
user: root
- startupJahiaHealthCheck: ${nodes.proc.first.id}
bulkCpUpgrade:
- cmd [proc]: |-
## [Upgrade] - 2/2
exit 0
- api: environment.control.RedeployContainersByGroup
nodeGroup: cp
tag: ${globals.targetDockerTag}
useExistingVolumes: ${globals.useExistingVolumes}
skipReinstall: false
envName: ${env.envName}
rollingCpUpgrade:
- cmd [proc]: |-
## [Upgrade] - 2/2
exit 0
- forEach (nodes.cp):
- api: environment.control.RedeployContainerById
nodeId: ${@i.id}
tag: ${globals.targetDockerTag}
useExistingVolumes: ${globals.useExistingVolumes}
skipReinstall: false
envName: ${env.envName}
# Add jahia version in /data/digital-factory-data/info/version.properties before redeploy
# in case we upgrade from a version that does not handle it to a version that does.
setVersionPropertiesValue:
- isVersionLower:
a : "${globals.targetDockerTag}"
b : "7.3.8.0"
res : isTargetVersionLowerThan7380
- if ( ! ${globals.isTargetVersionLowerThan7380} ):
- isVersionLower:
a : "${globals.targetDockerTag}"
b : "8.0.0.0"
res : isTargetVersionLowerThan8000
- isVersionLower:
a : "${globals.targetDockerTag}"
b : "8.0.2.0"
res : isTargetVersionLowerThan8020
- if ( ${globals.isTargetVersionLowerThan8000} || ! ${globals.isTargetVersionLowerThan8020} ):
# If the targetDockerTag < 8.0.0.0 or >= 8.0.2.0
cmd[proc,cp]: |-
INFO_DIR="/data/digital-factory-data/info"
if [ ! -f $INFO_DIR/version.properties ]; then
mkdir -p $INFO_DIR
echo "version=${nodes.proc.version}" > $INFO_DIR/version.properties
fi
user: tomcat
settings:
fields:
- name: targetVersion
type: string
caption: DX Target Version
vtype: text
required: false
tooltip: Optional. If you don't specify a version, the current Jahia version of the target environment will be selected.
- name: rollingUpgrade
type: toggle
caption: Rolling upgrade ?
value: false
required: false
tooltip: Redeploying cp nodes one at a time. Used for redeploying with the same Jahia version to run new image.