From b38b62182d40a036c40feaaa5922aebfd53277d3 Mon Sep 17 00:00:00 2001 From: Geoffrey van Wyk Date: Wed, 22 Nov 2023 09:25:27 +0200 Subject: [PATCH] fix: Idempotence failure with maintenance mode --- tasks/install_moodle.yml | 18 ++++++++++++------ tasks/reset_moodle.yml | 18 ++++++++++++------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/tasks/install_moodle.yml b/tasks/install_moodle.yml index 057540a..831933e 100644 --- a/tasks/install_moodle.yml +++ b/tasks/install_moodle.yml @@ -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: @@ -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 diff --git a/tasks/reset_moodle.yml b/tasks/reset_moodle.yml index 7459cbc..e122042 100644 --- a/tasks/reset_moodle.yml +++ b/tasks/reset_moodle.yml @@ -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 @@ -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