This commit is contained in:
foxcris 2021-03-06 11:43:59 +01:00
parent 6e72fb9a58
commit 88d59f97c2

View File

@ -1,176 +1,176 @@
---
# Detect wich databases have to backuped
# Default value is the "matrix_postgres_db_name"
# has to be extended for each service using a seperate db in postgres
# - name: Check if matrix_reminder_bot uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_bot_matrix_reminder_bot_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_bot_matrix_reminder_bot_database_engine == 'postgres'
# - name: Check if matrix_appservice_discord uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_discord_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_discord_database_engine == 'postgres'
# - name: Check if matrix_appservice_irc uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_irc_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_irc_database_engine == 'postgres'
# - name: Check if matrix_appservice_slack_database uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_slack_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_slack_database_engine == 'postgres'
# - name: Check if matrix_mautrix_facebook uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_facebook_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_facebook_database_engine == 'postgres'
# - name: Check if matrix_mautrix_hangouts uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_hangouts_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_hangouts_database_engine == 'postgres'
# - name: Check if matrix_mautrix_signal uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_signal_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_signal_database_engine == 'postgres'
# - name: Check if matrix_mautrix_telegram uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_telegram_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_telegram_database_engine == 'postgres'
# - name: Check if matrix_mautrix_whatsapp uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_whatsapp_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_whatsapp_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_discord uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_discord_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_discord_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_instagram uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_instagram_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_instagram_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_skype uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_skype_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_skype_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_slack uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_slack_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_slack_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_steam uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_steam_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_steam_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_twitter uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_twitter_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_twitter_database_engine == 'postgres'
# - name: Check if matrix_dimension uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_dimension_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_dimension_database_engine == 'postgres'
# - name: Check if matrix_etherpad uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_etherpad_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_etherpad_database_engine == 'postgres'
# - name: Check if matrix_ma1sd uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_ma1sd_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_ma1sd_database_engine == 'postgres'
# - name: Check if matrix_registration uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_registration_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_registration_database_engine == 'postgres'
#- name: Build list of all databases to backup - part 1
# set_fact:
# matrix_postgres_backup_db_list: '{% if item.enabled %}{% if matrix_postgres_backup_db_list=="" %}{{item.dbname}}{% else %}{{ matrix_postgres_backup_db_list }},{{item.dbname}}{% endif %}{% else %}{% endif %}'
# loop:
# - { enabled: '{{matrix_postgres_backup_matrix_reminder_bot_enabled|bool}}' , dbname: '{{ matrix_bot_matrix_reminder_bot_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_discord_enabled|bool}}' , dbname: '{{ matrix_appservice_discord_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_irc_enabled|bool}}' , dbname: '{{ matrix_appservice_irc_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_slack_enabled|bool}}' , dbname: '{{ matrix_appservice_slack_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_facebook_enabled|bool}}' , dbname: '{{ matrix_mautrix_facebook_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_hangouts_enabled|bool}}' , dbname: '{{ matrix_mautrix_hangouts_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_signal_enabled|bool}}' , dbname: '{{ matrix_mautrix_signal_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_telegram_enabled|bool}}' , dbname: '{{ matrix_mautrix_telegram_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_whatsapp_enabled|bool}}' , dbname: '{{ matrix_mautrix_whatsapp_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_instagram_enabled|bool}}' , dbname: '{{ matrix_postgres_backup_matrix_mx_puppet_instagram_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_skype_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_skype_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_slack_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_slack_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_steam_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_steam_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_twitter_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_twitter_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_dimension_enabled|bool}}' , dbname: '{{ matrix_dimension_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_etherpad_enabled|bool}}' , dbname: '{{ matrix_etherpad_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_ma1sd_enabled|bool}}' , dbname: '{{ matrix_ma1sd_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_registration_enabled|bool}}' , dbname: '{{ matrix_registration_database_engine }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_synapse_enabled|bool}}' , dbname: '{{ matrix_postgres_db_name }}' }
- name: Build list of all databases to backup - part 2
set_fact:
matrix_postgres_backup_db_list_prepare: "{% set res = [ ] %}{% for db in matrix_postgres_backup_db_dict %}{% if db.enabled %}{% set ignored = res.append(db.dbname) %}{% endif %}{% endfor %}{{ res }}"
- name: Build list of all databases to backup - part 1
set_fact:
matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list_prepare | join(',') }}"
- name: Going to backup the following list of databases
debug:
msg: "{{ matrix_postgres_backup_db_list }}"
when: matrix_postgres_backup_enabled|bool
---
# Detect wich databases have to backuped
# Default value is the "matrix_postgres_db_name"
# has to be extended for each service using a seperate db in postgres
# - name: Check if matrix_reminder_bot uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_bot_matrix_reminder_bot_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_bot_matrix_reminder_bot_database_engine == 'postgres'
# - name: Check if matrix_appservice_discord uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_discord_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_discord_database_engine == 'postgres'
# - name: Check if matrix_appservice_irc uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_irc_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_irc_database_engine == 'postgres'
# - name: Check if matrix_appservice_slack_database uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_appservice_slack_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_appservice_slack_database_engine == 'postgres'
# - name: Check if matrix_mautrix_facebook uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_facebook_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_facebook_database_engine == 'postgres'
# - name: Check if matrix_mautrix_hangouts uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_hangouts_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_hangouts_database_engine == 'postgres'
# - name: Check if matrix_mautrix_signal uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_signal_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_signal_database_engine == 'postgres'
# - name: Check if matrix_mautrix_telegram uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_telegram_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_telegram_database_engine == 'postgres'
# - name: Check if matrix_mautrix_whatsapp uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mautrix_whatsapp_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mautrix_whatsapp_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_discord uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_discord_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_discord_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_instagram uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_instagram_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_instagram_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_skype uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_skype_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_skype_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_slack uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_slack_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_slack_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_steam uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_steam_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_steam_database_engine == 'postgres'
# - name: Check if matrix_mx_puppet_twitter uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_mx_puppet_twitter_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_mx_puppet_twitter_database_engine == 'postgres'
# - name: Check if matrix_dimension uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_dimension_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_dimension_database_engine == 'postgres'
# - name: Check if matrix_etherpad uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_etherpad_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_etherpad_database_engine == 'postgres'
# - name: Check if matrix_ma1sd uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_ma1sd_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_ma1sd_database_engine == 'postgres'
# - name: Check if matrix_registration uses postgres database
# set_fact:
# matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list }},{{ matrix_registration_database_name }}"
# when:
# - matrix_postgres_backup_enabled|bool
# - matrix_registration_database_engine == 'postgres'
#- name: Build list of all databases to backup - part 1
# set_fact:
# matrix_postgres_backup_db_list: '{% if item.enabled %}{% if matrix_postgres_backup_db_list=="" %}{{item.dbname}}{% else %}{{ matrix_postgres_backup_db_list }},{{item.dbname}}{% endif %}{% else %}{% endif %}'
# loop:
# - { enabled: '{{matrix_postgres_backup_matrix_reminder_bot_enabled|bool}}' , dbname: '{{ matrix_bot_matrix_reminder_bot_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_discord_enabled|bool}}' , dbname: '{{ matrix_appservice_discord_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_irc_enabled|bool}}' , dbname: '{{ matrix_appservice_irc_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_appservice_slack_enabled|bool}}' , dbname: '{{ matrix_appservice_slack_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_facebook_enabled|bool}}' , dbname: '{{ matrix_mautrix_facebook_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_hangouts_enabled|bool}}' , dbname: '{{ matrix_mautrix_hangouts_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_signal_enabled|bool}}' , dbname: '{{ matrix_mautrix_signal_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_telegram_enabled|bool}}' , dbname: '{{ matrix_mautrix_telegram_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mautrix_whatsapp_enabled|bool}}' , dbname: '{{ matrix_mautrix_whatsapp_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_instagram_enabled|bool}}' , dbname: '{{ matrix_postgres_backup_matrix_mx_puppet_instagram_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_skype_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_skype_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_slack_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_slack_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_steam_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_steam_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_mx_puppet_twitter_enabled|bool}}' , dbname: '{{ matrix_mx_puppet_twitter_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_dimension_enabled|bool}}' , dbname: '{{ matrix_dimension_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_etherpad_enabled|bool}}' , dbname: '{{ matrix_etherpad_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_ma1sd_enabled|bool}}' , dbname: '{{ matrix_ma1sd_database_name }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_registration_enabled|bool}}' , dbname: '{{ matrix_registration_database_engine }}' }
# - { enabled: '{{matrix_postgres_backup_matrix_synapse_enabled|bool}}' , dbname: '{{ matrix_postgres_db_name }}' }
- name: Build list of all databases to backup - part 2
set_fact:
matrix_postgres_backup_db_list_prepare: "{% set res = [ ] %}{% for db in matrix_postgres_backup_db_dict %}{% if db.enabled %}{% set ignored = res.append(db.dbname) %}{% endif %}{% endfor %}{{ res }}"
- name: Build list of all databases to backup - part 1
set_fact:
matrix_postgres_backup_db_list: "{{ matrix_postgres_backup_db_list_prepare | join(',') }}"
- name: Going to backup the following list of databases
debug:
msg: "{{ matrix_postgres_backup_db_list }}"
when: matrix_postgres_backup_enabled|bool