Skip to content

Commit

Permalink
fix: Cannot copy database
Browse files Browse the repository at this point in the history
* fix: Cannot copy database

* fix: Idempotence failure with maintenance mode
  • Loading branch information
geoffreyvanwyk authored Nov 22, 2023
1 parent 3d38ae2 commit 2bf6c24
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
21 changes: 21 additions & 0 deletions tasks/install_moodle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
21 changes: 21 additions & 0 deletions tasks/reset_moodle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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.

0 comments on commit 2bf6c24

Please sign in to comment.