From b55e9131667a35e17c5569791d0a1e8f67f2b779 Mon Sep 17 00:00:00 2001 From: Geoffrey van Wyk Date: Wed, 22 Nov 2023 08:58:41 +0200 Subject: [PATCH] fix: Cannot copy database --- tasks/install_moodle.yml | 21 +++++++++++++++++++++ tasks/reset_moodle.yml | 21 +++++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/tasks/install_moodle.yml b/tasks/install_moodle.yml index ed84fd5..057540a 100644 --- a/tasks/install_moodle.yml +++ b/tasks/install_moodle.yml @@ -39,6 +39,21 @@ sandbox_moodle_instance: >- {{ sandbox_domain }}-moodle-{{ sandbox_item.version }} +- name: Set PHP version + ansible.builtin.set_fact: + sandbox_php_version: "{{ + '8.1' if (sandbox_item.branch == 'MOODLE_402_STABLE') or + (sandbox_item.branch == 'MOODLE_401_STABLE') + else '8.0' if (sandbox_item.branch == 'MOODLE_400_STABLE') or + (sandbox_item.branch == 'MOODLE_311_STABLE') + else '7.4' }}" + +- name: Enable Moodle's maintenance mode {{ sandbox_item.version }} + ansible.builtin.command: + chdir: /var/www/html/moodle-{{ sandbox_item.version }} + cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --enable + changed_when: yes + - name: Does archive of moodledata exists for Moodle {{ sandbox_item.version }}? ansible.builtin.stat: path: /var/www/moodledata-fresh-{{ sandbox_moodle_instance }}.tar.gz @@ -105,3 +120,9 @@ name: moodle-{{ sandbox_item.version | replace(".", "") }}-next state: present template: moodle-{{ sandbox_item.version | replace(".", "") }} + +- name: Disable Moodle's maintenance mode {{ sandbox_item.version }} + ansible.builtin.command: + chdir: /var/www/html/moodle-{{ sandbox_item.version }} + cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --disable + changed_when: yes diff --git a/tasks/reset_moodle.yml b/tasks/reset_moodle.yml index 5fa7ab9..7459cbc 100644 --- a/tasks/reset_moodle.yml +++ b/tasks/reset_moodle.yml @@ -25,6 +25,21 @@ sandbox_moodle_instance: >- {{ sandbox_domain }}-moodle-{{ sandbox_item.version }} +- name: Set PHP version + ansible.builtin.set_fact: + sandbox_php_version: "{{ + '8.1' if (sandbox_item.branch == 'MOODLE_402_STABLE') or + (sandbox_item.branch == 'MOODLE_401_STABLE') + else '8.0' if (sandbox_item.branch == 'MOODLE_400_STABLE') or + (sandbox_item.branch == 'MOODLE_311_STABLE') + else '7.4' }}" + +- name: Enable Moodle's maintenance mode {{ sandbox_item.version }} + ansible.builtin.command: + chdir: /var/www/html/moodle-{{ sandbox_item.version }} + cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --enable + changed_when: yes + - name: Rename current moodledata to old {{ sandbox_item.version }} become: yes ansible.builtin.command: @@ -93,3 +108,9 @@ name: moodle-{{ sandbox_item.version | replace(".", "") }}-next state: present template: moodle-{{ sandbox_item.version | replace(".", "") }}-fresh + +- name: Disable Moodle's maintenance mode {{ sandbox_item.version }} + ansible.builtin.command: + chdir: /var/www/html/moodle-{{ sandbox_item.version }} + cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --disable + changed_when: yes