Use yaml syntax instead of key=value syntax consistentlypull/68/head
| @@ -3,38 +3,48 @@ | |||
| # Pre-checks | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `server_path_media_store` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `server_path_media_store` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "server_path_media_store is not defined or server_path_media_store.startswith('<')" | |||
| - name: Fail if media store is on Amazon S3 | |||
| fail: msg="Your media store is on Amazon S3. Due to technical limitations, restoring is not supported." | |||
| fail: | |||
| msg: "Your media store is on Amazon S3. Due to technical limitations, restoring is not supported." | |||
| when: "matrix_s3_media_store_enabled" | |||
| - name: Check if the provided media store directory exists | |||
| stat: path="{{ server_path_media_store }}" | |||
| stat: | |||
| path: "{{ server_path_media_store }}" | |||
| register: server_path_media_store_stat | |||
| - name: Fail if provided media store directory doesn't exist on the server | |||
| fail: msg="{{ server_path_media_store }} cannot be found on the server" | |||
| fail: | |||
| msg: "{{ server_path_media_store }} cannot be found on the server" | |||
| when: "not server_path_media_store_stat.stat.exists or not server_path_media_store_stat.stat.isdir" | |||
| - name: Check if media store contains local_content | |||
| stat: path="{{ server_path_media_store }}/local_content" | |||
| stat: | |||
| path: "{{ server_path_media_store }}/local_content" | |||
| register: server_path_media_store_local_content_stat | |||
| - name: Check if media store contains remote_content | |||
| stat: path="{{ server_path_media_store }}/remote_content" | |||
| stat: | |||
| path: "{{ server_path_media_store }}/remote_content" | |||
| register: server_path_media_store_remote_content_stat | |||
| - name: Fail if media store directory doesn't look okay (lacking remote and local content) | |||
| fail: msg="{{ server_path_media_store }} contains neither local_content nor remote_content directories. It's most likely a mistake and is not a media store directory." | |||
| fail: | |||
| msg: "{{ server_path_media_store }} contains neither local_content nor remote_content directories. It's most likely a mistake and is not a media store directory." | |||
| when: "not server_path_media_store_local_content_stat.stat.exists and not server_path_media_store_remote_content_stat.stat.exists" | |||
| # Actual import work | |||
| - name: Ensure matrix-synapse is stopped | |||
| service: name=matrix-synapse state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-synapse | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| # This can only work with local files, not if the media store is on Amazon S3, | |||
| @@ -64,7 +74,10 @@ | |||
| # all files become owned by whoever needs to own them. | |||
| - name: Ensure Matrix Synapse is started (if it previously was) | |||
| service: name="{{ item }}" state=started daemon_reload=yes | |||
| service: | |||
| name: "{{ item }}" | |||
| state: started | |||
| daemon_reload: yes | |||
| when: stopping_result.changed | |||
| with_items: | |||
| - matrix-synapse | |||
| @@ -3,21 +3,25 @@ | |||
| # Pre-checks | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `server_path_postgres_dump` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `server_path_postgres_dump` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "server_path_postgres_dump is not defined or server_path_postgres_dump.startswith('<')" | |||
| - name: Check if the provided Postgres dump file exists | |||
| stat: path="{{ server_path_postgres_dump }}" | |||
| stat: | |||
| path: "{{ server_path_postgres_dump }}" | |||
| register: result_server_path_postgres_dump_stat | |||
| - name: Fail if provided Postgres dump file doesn't exists | |||
| fail: msg="File cannot be found on the server at {{ server_path_postgres_dump }}" | |||
| fail: | |||
| msg: "File cannot be found on the server at {{ server_path_postgres_dump }}" | |||
| when: not result_server_path_postgres_dump_stat.stat.exists | |||
| - import_tasks: tasks/util/detect_existing_postgres_version.yml | |||
| - name: Abort, if no existing Postgres version detected | |||
| fail: msg="Could not find existing Postgres installation" | |||
| fail: | |||
| msg: "Could not find existing Postgres installation" | |||
| when: "not matrix_postgres_detected_existing" | |||
| @@ -32,7 +36,10 @@ | |||
| # Actual import work | |||
| - name: Ensure matrix-postgres is started | |||
| service: name=matrix-postgres state=started daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| state: started | |||
| daemon_reload: yes | |||
| - name: Wait a bit, so that Postgres can start | |||
| wait_for: | |||
| @@ -3,15 +3,18 @@ | |||
| # Pre-checks | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `server_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `server_path_homeserver_db` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "server_path_homeserver_db is not defined or server_path_homeserver_db.startswith('<')" | |||
| - name: Check if the provided SQLite homeserver.db file exists | |||
| stat: path="{{ server_path_homeserver_db }}" | |||
| stat: | |||
| path: "{{ server_path_homeserver_db }}" | |||
| register: result_server_path_homeserver_db_stat | |||
| - name: Fail if provided SQLite homeserver.db file doesn't exist | |||
| fail: msg="File cannot be found on the server at {{ server_path_homeserver_db }}" | |||
| fail: | |||
| msg: "File cannot be found on the server at {{ server_path_homeserver_db }}" | |||
| when: not result_server_path_homeserver_db_stat.stat.exists | |||
| @@ -26,7 +29,10 @@ | |||
| # Actual import work | |||
| - name: Ensure matrix-postgres is stopped | |||
| service: name=matrix-postgres state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| state: stopped | |||
| daemon_reload: yes | |||
| - name: Ensure postgres data is wiped out | |||
| file: | |||
| @@ -42,7 +48,10 @@ | |||
| group: "{{ matrix_user_username }}" | |||
| - name: Ensure matrix-postgres is started | |||
| service: name=matrix-postgres state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| state: restarted | |||
| daemon_reload: yes | |||
| - name: Wait a bit, so that Postgres can start | |||
| wait_for: | |||
| @@ -1,24 +1,31 @@ | |||
| --- | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `username` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `username` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "username is not defined or username == '<your-username>'" | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `password` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `password` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "password is not defined or password == '<your-password>'" | |||
| - name: Fail if playbook called incorrectly | |||
| fail: msg="The `admin` variable needs to be provided to this playbook, via --extra-vars" | |||
| fail: | |||
| msg: "The `admin` variable needs to be provided to this playbook, via --extra-vars" | |||
| when: "admin is not defined or admin not in ['yes', 'no']" | |||
| - name: Ensure matrix-synapse is started | |||
| service: name=matrix-synapse state=started daemon_reload=yes | |||
| service: | |||
| name: matrix-synapse | |||
| state: started | |||
| daemon_reload: yes | |||
| register: start_result | |||
| - name: Wait a while, so that Matrix Synapse can manage to start | |||
| pause: seconds=7 | |||
| pause: | |||
| seconds: 7 | |||
| when: start_result.changed | |||
| - name: Register user | |||
| shell: "/usr/local/bin/matrix-synapse-register-user {{ username }} {{ password }} {{ '1' if admin == 'yes' else '0' }}" | |||
| shell: "/usr/local/bin/matrix-synapse-register-user {{ username }} {{ password }} {{ '1' if admin == 'yes' else '0' }}" | |||
| @@ -68,11 +68,17 @@ | |||
| when: ansible_os_family == 'Debian' | |||
| - name: Ensure firewalld is started and autoruns | |||
| service: name=firewalld state=started enabled=yes | |||
| service: | |||
| name: firewalld | |||
| state: started | |||
| enabled: yes | |||
| when: ansible_os_family == 'RedHat' | |||
| - name: Ensure Docker is started and autoruns | |||
| service: name=docker state=started enabled=yes | |||
| service: | |||
| name: docker | |||
| state: started | |||
| enabled: yes | |||
| - name: Ensure ntpd is started and autoruns | |||
| service: | |||
| @@ -9,7 +9,8 @@ | |||
| # This will throw a Permission Denied error if already mounted | |||
| - name: Check Matrix Goofys external storage mountpoint path | |||
| stat: path="{{ matrix_synapse_media_store_path }}" | |||
| stat: | |||
| path: "{{ matrix_synapse_media_store_path }}" | |||
| register: local_path_matrix_synapse_media_store_path_stat | |||
| ignore_errors: yes | |||
| when: matrix_s3_media_store_enabled | |||
| @@ -43,11 +44,15 @@ | |||
| # | |||
| - name: Check existence of matrix-goofys service | |||
| stat: path="/etc/systemd/system/matrix-goofys.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-goofys.service" | |||
| register: matrix_goofys_service_stat | |||
| - name: Ensure matrix-goofys is stopped | |||
| service: name=matrix-goofys state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-goofys | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| when: "not matrix_s3_media_store_enabled and matrix_goofys_service_stat.stat.exists" | |||
| @@ -29,11 +29,15 @@ | |||
| # | |||
| - name: Check existence of matrix-mailer service | |||
| stat: path="/etc/systemd/system/matrix-mailer.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-mailer.service" | |||
| register: matrix_mailer_service_stat | |||
| - name: Ensure matrix-mailer is stopped | |||
| service: name=matrix-mailer state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-mailer | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| when: "not matrix_mailer_enabled and matrix_mailer_service_stat.stat.exists" | |||
| @@ -53,4 +57,4 @@ | |||
| docker_image: | |||
| name: "{{ matrix_mailer_docker_image }}" | |||
| state: absent | |||
| when: "not matrix_mailer_enabled" | |||
| when: "not matrix_mailer_enabled" | |||
| @@ -52,11 +52,15 @@ | |||
| # | |||
| - name: Check existence of matrix-mxisd service | |||
| stat: path="/etc/systemd/system/matrix-mxisd.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-mxisd.service" | |||
| register: matrix_mxisd_service_stat | |||
| - name: Ensure matrix-mxisd is stopped | |||
| service: name=matrix-mxisd state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-mxisd | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| when: "not matrix_mxisd_enabled and matrix_mxisd_service_stat.stat.exists" | |||
| @@ -76,4 +80,4 @@ | |||
| docker_image: | |||
| name: "{{ matrix_mxisd_docker_image }}" | |||
| state: absent | |||
| when: "not matrix_mxisd_enabled" | |||
| when: "not matrix_mxisd_enabled" | |||
| @@ -69,11 +69,15 @@ | |||
| # | |||
| - name: Check existence of matrix-nginx-proxy service | |||
| stat: path="/etc/systemd/system/matrix-nginx-proxy.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-nginx-proxy.service" | |||
| register: matrix_nginx_proxy_service_stat | |||
| - name: Ensure matrix-nginx-proxy is stopped | |||
| service: name=matrix-nginx-proxy state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-nginx-proxy | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| when: "not matrix_nginx_proxy_enabled and matrix_nginx_proxy_service_stat.stat.exists" | |||
| @@ -69,12 +69,16 @@ | |||
| # | |||
| - name: Check existence of matrix-postgres service | |||
| stat: path="/etc/systemd/system/matrix-postgres.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-postgres.service" | |||
| register: matrix_postgres_service_stat | |||
| when: matrix_postgres_use_external | |||
| - name: Ensure matrix-postgres is stopped | |||
| service: name=matrix-postgres state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| state: stopped | |||
| daemon_reload: yes | |||
| when: "matrix_postgres_use_external and matrix_postgres_service_stat.stat.exists" | |||
| - name: Ensure matrix-postgres.service doesn't exist | |||
| @@ -84,7 +88,8 @@ | |||
| when: "matrix_postgres_use_external and matrix_postgres_service_stat.stat.exists" | |||
| - name: Check existence of matrix-postgres local data path | |||
| stat: path="{{ matrix_postgres_data_path }}" | |||
| stat: | |||
| path: "{{ matrix_postgres_data_path }}" | |||
| register: matrix_postgres_data_path_stat | |||
| when: matrix_postgres_use_external | |||
| @@ -43,11 +43,15 @@ | |||
| # | |||
| - name: Check existence of matrix-riot-web service | |||
| stat: path="/etc/systemd/system/matrix-riot-web.service" | |||
| stat: | |||
| path: "/etc/systemd/system/matrix-riot-web.service" | |||
| register: matrix_riot_web_service_stat | |||
| - name: Ensure matrix-riot-web is stopped | |||
| service: name=matrix-riot-web state=stopped daemon_reload=yes | |||
| service: | |||
| name: matrix-riot-web | |||
| state: stopped | |||
| daemon_reload: yes | |||
| register: stopping_result | |||
| when: "not matrix_riot_web_enabled and matrix_riot_web_service_stat.stat.exists" | |||
| @@ -33,7 +33,8 @@ | |||
| mode: 0644 | |||
| when: "matrix_mautrix_telegram_enabled" | |||
| - stat: "path={{ matrix_mautrix_telegram_base_path }}/registration.yaml" | |||
| - stat: | |||
| path: "{{ matrix_mautrix_telegram_base_path }}/registration.yaml" | |||
| register: mautrix_telegram_registration_file | |||
| - name: Generate matrix-mautrix-telegram registration.yaml if it doesn't exist | |||
| @@ -33,7 +33,8 @@ | |||
| mode: 0644 | |||
| when: "matrix_mautrix_whatsapp_enabled" | |||
| - stat: "path={{ matrix_mautrix_whatsapp_base_path }}/registration.yaml" | |||
| - stat: | |||
| path: "{{ matrix_mautrix_whatsapp_base_path }}/registration.yaml" | |||
| register: mautrix_whatsapp_registration_file | |||
| - name: Generate matrix-mautrix-whatsapp registration.yaml if it doesn't exist | |||
| @@ -2,7 +2,8 @@ | |||
| # This will throw a Permission Denied error if already mounted using fuse | |||
| - name: Check Matrix Synapse media store path | |||
| stat: path="{{ matrix_synapse_media_store_path }}" | |||
| stat: | |||
| path: "{{ matrix_synapse_media_store_path }}" | |||
| register: local_path_media_store_stat | |||
| ignore_errors: yes | |||
| @@ -1,43 +1,87 @@ | |||
| --- | |||
| - name: Ensure matrix-postgres autoruns and is restarted | |||
| service: name=matrix-postgres enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: "not matrix_postgres_use_external" | |||
| - name: Ensure matrix-goofys autoruns and is restarted | |||
| service: name=matrix-goofys enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-goofys | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_s3_media_store_enabled | |||
| - name: Ensure matrix-coturn autoruns and is restarted | |||
| service: name=matrix-coturn enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-coturn | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| - name: Ensure matrix-mailer autoruns and is restarted | |||
| service: name=matrix-mailer enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-mailer | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_mailer_enabled | |||
| - name: Ensure matrix-mxisd autoruns and is restarted | |||
| service: name=matrix-mxisd enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-mxisd | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_mxisd_enabled | |||
| - name: Ensure matrix-synapse autoruns and is restarted | |||
| service: name=matrix-synapse enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-synapse | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| - name: Ensure matrix-riot-web autoruns and is restarted | |||
| service: name=matrix-riot-web enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-riot-web | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_riot_web_enabled | |||
| - name: Ensure matrix-nginx-proxy autoruns and is restarted | |||
| service: name=matrix-nginx-proxy enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-nginx-proxy | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_nginx_proxy_enabled | |||
| - name: Ensure matrix-corporal autoruns and is restarted | |||
| service: name=matrix-corporal enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-corporal | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_corporal_enabled | |||
| - name: Ensure matrix-mautrix-telegram autoruns and is restarted | |||
| service: name=matrix-mautrix-telegram enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-mautrix-telegram | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_mautrix_telegram_enabled | |||
| - name: Ensure matrix-mautrix-whatsapp autoruns and is restarted | |||
| service: name=matrix-mautrix-whatsapp enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-mautrix-whatsapp | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| when: matrix_mautrix_whatsapp_enabled | |||
| @@ -38,21 +38,28 @@ | |||
| - import_tasks: tasks/util/detect_existing_postgres_version.yml | |||
| - name: Abort, if no existing Postgres version detected | |||
| fail: msg="Could not find existing Postgres installation" | |||
| fail: | |||
| msg: "Could not find existing Postgres installation" | |||
| when: "not matrix_postgres_detected_existing" | |||
| - name: Abort, if already at latest Postgres version | |||
| fail: msg="You are already running the latest Postgres version supported ({{ matrix_postgres_docker_image_latest }}). Nothing to do" | |||
| fail: | |||
| msg: "You are already running the latest Postgres version supported ({{ matrix_postgres_docker_image_latest }}). Nothing to do" | |||
| when: "matrix_postgres_detected_version_corresponding_docker_image == matrix_postgres_docker_image_latest" | |||
| - debug: | |||
| msg: "Upgrading database from {{ matrix_postgres_detected_version_corresponding_docker_image }} to {{ matrix_postgres_docker_image_latest }}" | |||
| - name: Ensure matrix-synapse is stopped | |||
| service: name=matrix-synapse state=stopped | |||
| service: | |||
| name: matrix-synapse | |||
| state: stopped | |||
| - name: Ensure matrix-postgres is started | |||
| service: name=matrix-postgres state=started daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| state: started | |||
| daemon_reload: yes | |||
| - name: Wait a bit, so that Postgres can start | |||
| wait_for: | |||
| @@ -69,7 +76,9 @@ | |||
| {{ matrix_postgres_detected_version_corresponding_docker_image }} pg_dump -h matrix-postgres {{ matrix_postgres_db_name }} -f /out/{{ postgres_dump_name }} | |||
| - name: Ensure matrix-postgres is stopped | |||
| service: name=matrix-postgres state=stopped | |||
| service: | |||
| name: matrix-postgres | |||
| state: stopped | |||
| - name: Rename existing Postgres data directory | |||
| command: "mv {{ matrix_postgres_data_path }} {{ postgres_auto_upgrade_backup_data_path }}" | |||
| @@ -80,7 +89,11 @@ | |||
| - import_tasks: tasks/setup/setup_postgres.yml | |||
| - name: Ensure matrix-postgres autoruns and is restarted | |||
| service: name=matrix-postgres enabled=yes state=restarted daemon_reload=yes | |||
| service: | |||
| name: matrix-postgres | |||
| enabled: yes | |||
| state: restarted | |||
| daemon_reload: yes | |||
| - name: Wait a bit, so that Postgres can start | |||
| wait_for: | |||
| @@ -102,7 +115,10 @@ | |||
| state: absent | |||
| - name: Ensure matrix-synapse is started | |||
| service: name=matrix-synapse state=started daemon_reload=yes | |||
| service: | |||
| name: matrix-synapse | |||
| state: started | |||
| daemon_reload: yes | |||
| - debug: | |||
| msg: "NOTE: Your old Postgres data directory is preserved at `{{ postgres_auto_upgrade_backup_data_path }}`. You might want to get rid of it once you've confirmed that all is well." | |||