Skip to content

Commit 2e6139d

Browse files
Merge pull request #13 from wcm-io-devops/feature/in-place-upgrade
Add AEM in-place-upgrade functionality
2 parents 61c1131 + ce0625e commit 2e6139d

File tree

6 files changed

+94
-2
lines changed

6 files changed

+94
-2
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ env:
66
# run against latest version
77
- ANSIBLE_VERSION=latest
88
# run against minimal required version
9-
- ANSIBLE_VERSION=2.2.*
9+
- ANSIBLE_VERSION=2.4.*
1010

1111
# Use the new container infrastructure
1212
sudo: false

README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,30 @@ Sets the `nofile` limit for the AEM user.
8383

8484
Controls if Java is installed by using [srsp.oracle-java](https://galaxy.ansible.com/srsp/oracle-java/) role for installing Java.
8585

86+
aem_cms_in_place_upgrade: false
87+
88+
Enables / disables in-place-upgrade.
89+
90+
:exclamation: Warnings
91+
* Use the in place upgrade functionality with care and test it in a
92+
staging environment before applying it to production!
93+
* Do not use this mechanism when a content repository migration is
94+
necessary!
95+
* Do not use this mechanism when upgrading from AEM 6.2 to AEM 6.3+
96+
97+
```
98+
aem_cms_in_place_upgrade_paths:
99+
"6.3.0":
100+
- "6.4.0"
101+
```
102+
103+
Format:
104+
105+
"from_version":
106+
- "to_version" # list of versions that an upgrade is allowed for
107+
108+
Specifies from and to versions which are supported by the
109+
in-place-upgrade mechanism.
86110

87111
## Dependencies
88112

defaults/main.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,14 @@ aem_cms_limit_nofile: 20000
5555

5656
# controls if the java dependency is enabled/disabled
5757
aem_cms_dependency_java: true
58+
59+
# Enables / disables in-place-upgrade
60+
aem_cms_in_place_upgrade: false
61+
62+
# Specifies from and to versions which are supported for an in-place-upgrade
63+
aem_cms_in_place_upgrade_paths:
64+
"6.3.0":
65+
- "6.4.0"
66+
# "from_version":
67+
# - "to_version" # list of versions that an upgrade is allowed for
68+

meta/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ galaxy_info:
55
company: pro!vision
66
issue_tracker_url: https://wcm-io.atlassian.net
77
license: Apache
8-
min_ansible_version: 2.2
8+
min_ansible_version: 2.4
99

1010
platforms:
1111
- name: Ubuntu

tasks/in_place_upgrade.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# get the latest version of all the existing jar files
2+
- name: "in_place_upgrade : detect version to upgrade from."
3+
set_fact:
4+
aem_cms_in_place_upgrade_existing_version: "{{ aem_cms_in_place_upgrade_existing_quickstarts | map('regex_replace', '^.*cq-quickstart-(.+)-standalone-quickstart.jar$', '\\1') | list | sort | reverse | list | first}}"
5+
6+
# safe gate which only allows upgrades when allowed
7+
- name: "in_place_upgrade : fail when upgrade is not allowed."
8+
fail:
9+
msg:
10+
- "In place upgrade is not allowed, 'aem_cms_in_place_upgrade' is set to '{{ aem_cms_in_place_upgrade }}'"
11+
- "existing version: '{{ aem_cms_in_place_upgrade_existing_version }}'"
12+
- "version to deploy: '{{ aem_cms_version }}'"
13+
when: not aem_cms_in_place_upgrade
14+
15+
# fail on downgrade
16+
- name: "in_place_upgrade : fail on downgrade."
17+
fail:
18+
msg:
19+
- "Downgrading is not allowed/supported!"
20+
- "existing version: '{{ aem_cms_in_place_upgrade_existing_version }}'"
21+
- "version to deploy: '{{ aem_cms_version }}'"
22+
when: aem_cms_version is version_compare(aem_cms_in_place_upgrade_existing_version, '<')
23+
24+
# check if upgrading is allowed based on existing and new version
25+
- name: "in_place_upgrade : fail when upgrade path from '{{ aem_cms_in_place_upgrade_existing_version }}' to '{{ aem_cms_version }}' is not allowed."
26+
fail:
27+
msg: "Upgrade from {{ aem_cms_in_place_upgrade_existing_version }} to {{ aem_cms_version }} is not allowed."
28+
when: aem_cms_in_place_upgrade_paths[aem_cms_in_place_upgrade_existing_version] is not defined or
29+
aem_cms_version not in aem_cms_in_place_upgrade_paths[aem_cms_in_place_upgrade_existing_version]
30+
31+
# ensure instance is stopped before renaming the jars
32+
- name: "in_place_upgrade : stopping existing instance for upgrade."
33+
service:
34+
name: "{{ aem_cms_service_name }}"
35+
state: stopped
36+
37+
# rename old quickstart jars to *.jar.bak because default start script will use first jar found in the app folder
38+
- name: "in_place_upgrade : create a backup of existing quickstart(s)."
39+
command: "mv {{ item }} {{ item }}.bak"
40+
changed_when: true
41+
with_items: "{{ aem_cms_in_place_upgrade_existing_quickstarts }}"

tasks/main.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,22 @@
3636
(aem_cms_quickstart_sha1 is defined and
3737
(aem_cms_quickstart_sha1 | lower) != aem_cms_quickstart_file.stat.checksum)
3838

39+
- name: "Check for existing AEM installation with versions different than {{ aem_cms_version }}."
40+
find:
41+
paths: "{{ aem_cms_home }}/crx-quickstart/app/"
42+
patterns:
43+
- "cq-quickstart-*-standalone-quickstart.jar"
44+
register: aem_cms_existing_quickstarts
45+
46+
- name: "Set fact with existing quickstart paths."
47+
set_fact:
48+
aem_cms_in_place_upgrade_existing_quickstarts: "{{ aem_cms_existing_quickstarts.files | map(attribute='path') | list }}"
49+
50+
- name: Include tasks for in-place-upgrade when necessary.
51+
include_tasks: in_place_upgrade.yml
52+
# only perform in place upgrade when no jar containing aem_cms_version is present
53+
when: aem_cms_in_place_upgrade_existing_quickstarts | map('basename') | list | select('search', aem_cms_version) | list | length == 0
54+
3955
- name: Unpack AEM.
4056
shell: "su {{ aem_cms_user }} -l -c 'java -jar {{ aem_cms_download_path }}/{{ aem_cms_quickstart_name }} -unpack -b {{ aem_cms_home }}'"
4157
args:

0 commit comments

Comments
 (0)