Skip to content

Commit

Permalink
fix: Idempotence failure with maintenance mode
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffreyvanwyk committed Nov 22, 2023
1 parent b55e913 commit b38b621
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 12 deletions.
18 changes: 12 additions & 6 deletions tasks/install_moodle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,13 @@
else '7.4' }}"

- name: Enable Moodle's maintenance mode {{ sandbox_item.version }}
ansible.builtin.command:
ansible.builtin.shell:
chdir: /var/www/html/moodle-{{ sandbox_item.version }}
cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --enable
changed_when: yes
cmd: >
php{{ sandbox_php_version }} admin/cli/maintenance.php --enable
&&
touch maintenance.enabled
creates: /var/www/html/moodle-{{ sandbox_item.version }}/maintenance.enabled

- name: Does archive of moodledata exists for Moodle {{ sandbox_item.version }}?
ansible.builtin.stat:
Expand Down Expand Up @@ -122,7 +125,10 @@
template: moodle-{{ sandbox_item.version | replace(".", "") }}

- name: Disable Moodle's maintenance mode {{ sandbox_item.version }}
ansible.builtin.command:
ansible.builtin.shell:
chdir: /var/www/html/moodle-{{ sandbox_item.version }}
cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --disable
changed_when: yes
cmd: >
php{{ sandbox_php_version }} admin/cli/maintenance.php --disable
&&
rm maintenance.enabled
removes: /var/www/html/moodle-{{ sandbox_item.version }}/maintenance.enabled
18 changes: 12 additions & 6 deletions tasks/reset_moodle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,13 @@
else '7.4' }}"

- name: Enable Moodle's maintenance mode {{ sandbox_item.version }}
ansible.builtin.command:
ansible.builtin.shell:
chdir: /var/www/html/moodle-{{ sandbox_item.version }}
cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --enable
changed_when: yes
cmd: >
php{{ sandbox_php_version }} admin/cli/maintenance.php --enable
&&
touch maintenance.enabled
creates: /var/www/html/moodle-{{ sandbox_item.version }}/maintenance.enabled

- name: Rename current moodledata to old {{ sandbox_item.version }}
become: yes
Expand Down Expand Up @@ -110,7 +113,10 @@
template: moodle-{{ sandbox_item.version | replace(".", "") }}-fresh

- name: Disable Moodle's maintenance mode {{ sandbox_item.version }}
ansible.builtin.command:
ansible.builtin.shell:
chdir: /var/www/html/moodle-{{ sandbox_item.version }}
cmd: php{{ sandbox_php_version }} admin/cli/maintenance.php --disable
changed_when: yes
cmd: >
php{{ sandbox_php_version }} admin/cli/maintenance.php --disable
&&
rm maintenance.enabled
removes: /var/www/html/moodle-{{ sandbox_item.version }}/maintenance.enabled

0 comments on commit b38b621

Please sign in to comment.