Matrix Docker Ansible eploy
Non puoi selezionare più di 25 argomenti Gli argomenti devono iniziare con una lettera o un numero, possono includere trattini ('-') e possono essere lunghi fino a 35 caratteri.
 
 

108 righe
4.7 KiB

  1. # SPDX-FileCopyrightText: 2023 - 2024 Nikita Chernyi
  2. # SPDX-FileCopyrightText: 2023 - 2024 Slavi Pantaleev
  3. # SPDX-FileCopyrightText: 2024 Suguru Hirahara
  4. #
  5. # SPDX-License-Identifier: AGPL-3.0-or-later
  6. # Shows help
  7. default:
  8. @{{ just_executable() }} --list --justfile "{{ justfile() }}"
  9. # Initialize inventory files
  10. inventory domain ip:
  11. #!/usr/bin/env sh
  12. VARS_DIR="inventory/host_vars/{{ domain }}"
  13. VARS_FILE="inventory/host_vars/{{ domain }}/vars.yml"
  14. HOSTS_FILE="inventory/hosts"
  15. mkdir -p "$VARS_DIR"
  16. cp examples/vars.yml "$VARS_FILE"
  17. cp examples/hosts inventory/hosts
  18. sed -i 's/^matrix_domain:.*/matrix_domain: {{ domain }}/' "$VARS_FILE"
  19. PASSWORD=`openssl rand -base64 64 | head -c 64`; \
  20. sed -i "s#^matrix_homeserver_generic_secret_key:.*#matrix_homeserver_generic_secret_key: '$PASSWORD'#" "$VARS_FILE"
  21. sed -i 's/^matrix\.example\.com/{{ domain }}/' "$HOSTS_FILE"
  22. sed -i 's/ansible_host=<[^>]\+>/ansible_host={{ ip }}/' "$HOSTS_FILE"
  23. echo "Check and configure your files at:"
  24. echo $VARS_FILE
  25. echo $HOSTS_FILE
  26. # Pulls external Ansible roles
  27. roles:
  28. #!/usr/bin/env sh
  29. echo "[NOTE] This command just updates the roles, but if you want to update everything at once (playbook, roles, etc.) - use 'just update'"
  30. if [ -x "$(command -v agru)" ]; then
  31. agru
  32. else
  33. rm -rf roles/galaxy
  34. ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force
  35. fi
  36. # Updates the playbook and installs the necessary Ansible roles pinned in requirements.yml. If a -u flag is passed, also updates the requirements.yml file with new role versions (if available)
  37. update *flags: update-playbook-only
  38. #!/usr/bin/env sh
  39. if [ -x "$(command -v agru)" ]; then
  40. echo {{ if flags == "" { "Installing roles pinned in requirements.yml…" } else { if flags == "-u" { "Updating roles and pinning new versions in requirements.yml…" } else { "Unknown flags passed" } } }}
  41. agru {{ flags }}
  42. else
  43. echo "[NOTE] You are using the standard ansible-galaxy tool to install roles, which is slow and lacks other features. We recommend installing the 'agru' tool to speed up the process: https://github.com/etkecc/agru#where-to-get"
  44. echo "Installing roles…"
  45. rm -rf roles/galaxy
  46. ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force
  47. fi
  48. # Updates the playbook without installing/updating Ansible roles
  49. update-playbook-only:
  50. @echo "Updating playbook…"
  51. @git stash -q
  52. @git pull -q
  53. @-git stash pop -q
  54. # Runs ansible-lint against all roles in the playbook
  55. lint:
  56. ansible-lint
  57. # Runs the playbook with --tags=install-all,ensure-matrix-users-created,start and optional arguments
  58. install-all *extra_args: (run-tags "install-all,ensure-matrix-users-created,start" extra_args)
  59. # Runs installation tasks for a single service
  60. install-service service *extra_args:
  61. {{ just_executable() }} --justfile "{{ justfile() }}" run \
  62. --tags=install-{{ service }},start-group \
  63. --extra-vars=group={{ service }} \
  64. --extra-vars=devture_systemd_service_manager_service_restart_mode=one-by-one {{ extra_args }}
  65. # Runs the playbook with --tags=setup-all,ensure-matrix-users-created,start and optional arguments
  66. setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" extra_args)
  67. # Runs the playbook with the given list of arguments
  68. run +extra_args:
  69. ansible-playbook -i inventory/hosts setup.yml {{ extra_args }}
  70. # Runs the playbook with the given list of comma-separated tags and optional arguments
  71. run-tags tags *extra_args:
  72. {{ just_executable() }} --justfile "{{ justfile() }}" run --tags={{ tags }} {{ extra_args }}
  73. # Runs the playbook in user-registration mode
  74. register-user username password admin_yes_or_no *extra_args:
  75. ansible-playbook -i inventory/hosts setup.yml --tags=register-user --extra-vars="username={{ username }} password={{ password }} admin={{ admin_yes_or_no }}" {{ extra_args }}
  76. # Starts all services
  77. start-all *extra_args: (run-tags "start-all" extra_args)
  78. # Starts a specific service group
  79. start-group group *extra_args:
  80. @{{ just_executable() }} --justfile "{{ justfile() }}" run-tags start-group --extra-vars="group={{ group }}" {{ extra_args }}
  81. # Stops all services
  82. stop-all *extra_args: (run-tags "stop-all" extra_args)
  83. # Stops a specific service group
  84. stop-group group *extra_args:
  85. @{{ just_executable() }} --justfile "{{ justfile() }}" run-tags stop-group --extra-vars="group={{ group }}" {{ extra_args }}
  86. # Rebuilds the mautrix-meta-instagram Ansible role using the mautrix-meta-messenger role as a source
  87. rebuild-mautrix-meta-instagram:
  88. /bin/bash "{{ justfile_directory() }}/bin/rebuild-mautrix-meta-instagram.sh" "{{ justfile_directory() }}/roles/custom"