-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrademoodlebox.yml
50 lines (42 loc) · 1.64 KB
/
upgrademoodlebox.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
---
- name: playbook to upgrade the MoodleBox to the last version
hosts: all
vars:
ansible_user: '{{ moodlebox_username }}'
ansible_password: '{{ moodlebox_password }}'
upgrade_moodlebox: true
become: yes
vars_files:
- default.config.yml
pre_tasks:
- name: include customised variables
include_vars: '{{ item }}'
with_fileglob:
- config.yml
- name: get MoodleBox current version info
slurp:
src: "/etc/moodlebox-info"
register: moodleboxinfo
- name: set vars with MoodleBox current version number and date
set_fact:
current_version_number: "{{ (moodleboxinfo['content'] | b64decode).split('\n')[0] | regex_replace('^.*version (\\d+\\.\\d+\\.\\d+),.*$', '\\1') }}"
current_version_date: "{{ (moodleboxinfo['content'] | b64decode).split('\n')[0] | regex_replace('^.*, (\\d{4}-\\d{2}-\\d{2}).*$', '\\1') }}"
- name: inform that upgrade can proceed
debug:
msg: "Your MoodleBox version {{ current_version_number }} will be now upgraded automatically."
when:
current_version_number.split('.')[0] >= '2' and current_version_number != '2.6.0'
- name: alert that upgrade cannot proceed
debug:
msg: "Your MoodleBox version {{ current_version_number }} cannot be upgraded automatically."
when:
current_version_number.split('.')[0] < '2' or current_version_number == '2.6.0'
- name: aborts upgrade if version does not meet criteria
meta:
end_play
when:
current_version_number.split('.')[0] < '2' or current_version_number == '2.6.0'
roles:
- bootstrap
- install
- moodle