From 2bf6c2495e2e02b794ad265f5e8a1dd0bfbc51ff Mon Sep 17 00:00:00 2001 From: Geoffrey van Wyk Date: Wed, 22 Nov 2023 09:55:01 +0200 Subject: [PATCH] fix: Cannot copy database * fix: Cannot copy database * fix: Idempotence failure with maintenance mode --- 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..5ed52a3 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: no # Set for passing Molecule idempotency test. + - 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: no # Set for passing Molecule idempotency test. diff --git a/tasks/reset_moodle.yml b/tasks/reset_moodle.yml index 5fa7ab9..aab0c11 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: no # Set for passing Molecule idempotency test. + - 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: no # Set for passing Molecule idempotency test.