diff --git a/roles/web-app-moodle/tasks/01_database.yml b/roles/web-app-moodle/tasks/01_patch_config.yml similarity index 81% rename from roles/web-app-moodle/tasks/01_database.yml rename to roles/web-app-moodle/tasks/01_patch_config.yml index 1c46fbd5..10cc4155 100644 --- a/roles/web-app-moodle/tasks/01_database.yml +++ b/roles/web-app-moodle/tasks/01_patch_config.yml @@ -19,7 +19,7 @@ changed_when: false failed_when: false -- name: Patch Moodle config.php with updated DB credentials +- name: Patch Moodle config.php with updated DB and wwwroot credentials when: config_file_exists.rc == 0 block: - name: Update DB host @@ -41,3 +41,8 @@ command: > docker exec --user root {{ moodle_container }} sed -i "s/^\$CFG->dbpass *= *.*/\$CFG->dbpass = '{{ database_password }}';/" {{ moodle_config }} + + - name: Update CFG->wwwroot via sed in container + command: > + docker exec --user root {{ moodle_container }} + sed -i -E "s|^(\$CFG->wwwroot[[:space:]]*=[[:space:]]*).*$|\1'{{ domains | get_url(application_id, WEB_PROTOCOL) }}';|" {{ moodle_config }} diff --git a/roles/web-app-moodle/tasks/main.yml b/roles/web-app-moodle/tasks/main.yml index 74e9fa37..bb999496 100644 --- a/roles/web-app-moodle/tasks/main.yml +++ b/roles/web-app-moodle/tasks/main.yml @@ -4,7 +4,7 @@ name: cmp-db-docker-proxy - name: "Update database credentials" - include_tasks: 01_database.yml + include_tasks: 01_patch_config.yml - name: flush docker service meta: flush_handlers