Matrix Docker Ansible eploy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

88 regels
3.9 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. # Pulls external Ansible roles
  10. roles:
  11. #!/usr/bin/env sh
  12. echo "[NOTE] This command just updates the roles, but if you want to update everything at once (playbook, roles, etc.) - use 'just update'"
  13. if [ -x "$(command -v agru)" ]; then
  14. agru
  15. else
  16. rm -rf roles/galaxy
  17. ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force
  18. fi
  19. # 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)
  20. update *flags: update-playbook-only
  21. #!/usr/bin/env sh
  22. if [ -x "$(command -v agru)" ]; then
  23. 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" } } }}
  24. agru {{ flags }}
  25. else
  26. 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"
  27. echo "Installing roles…"
  28. rm -rf roles/galaxy
  29. ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force
  30. fi
  31. # Updates the playbook without installing/updating Ansible roles
  32. update-playbook-only:
  33. @echo "Updating playbook…"
  34. @git stash -q
  35. @git pull -q
  36. @-git stash pop -q
  37. # Runs ansible-lint against all roles in the playbook
  38. lint:
  39. ansible-lint
  40. # Runs the playbook with --tags=install-all,ensure-matrix-users-created,start and optional arguments
  41. install-all *extra_args: (run-tags "install-all,ensure-matrix-users-created,start" extra_args)
  42. # Runs installation tasks for a single service
  43. install-service service *extra_args:
  44. {{ just_executable() }} --justfile "{{ justfile() }}" run \
  45. --tags=install-{{ service }},start-group \
  46. --extra-vars=group={{ service }} \
  47. --extra-vars=devture_systemd_service_manager_service_restart_mode=one-by-one {{ extra_args }}
  48. # Runs the playbook with --tags=setup-all,ensure-matrix-users-created,start and optional arguments
  49. setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" extra_args)
  50. # Runs the playbook with the given list of arguments
  51. run +extra_args:
  52. ansible-playbook -i inventory/hosts setup.yml {{ extra_args }}
  53. # Runs the playbook with the given list of comma-separated tags and optional arguments
  54. run-tags tags *extra_args:
  55. {{ just_executable() }} --justfile "{{ justfile() }}" run --tags={{ tags }} {{ extra_args }}
  56. # Runs the playbook in user-registration mode
  57. register-user username password admin_yes_or_no *extra_args:
  58. ansible-playbook -i inventory/hosts setup.yml --tags=register-user --extra-vars="username={{ username }} password={{ password }} admin={{ admin_yes_or_no }}" {{ extra_args }}
  59. # Starts all services
  60. start-all *extra_args: (run-tags "start-all" extra_args)
  61. # Starts a specific service group
  62. start-group group *extra_args:
  63. @{{ just_executable() }} --justfile "{{ justfile() }}" run-tags start-group --extra-vars="group={{ group }}" {{ extra_args }}
  64. # Stops all services
  65. stop-all *extra_args: (run-tags "stop-all" extra_args)
  66. # Stops a specific service group
  67. stop-group group *extra_args:
  68. @{{ just_executable() }} --justfile "{{ justfile() }}" run-tags stop-group --extra-vars="group={{ group }}" {{ extra_args }}
  69. # Rebuilds the mautrix-meta-instagram Ansible role using the mautrix-meta-messenger role as a source
  70. rebuild-mautrix-meta-instagram:
  71. /bin/bash "{{ justfile_directory() }}/bin/rebuild-mautrix-meta-instagram.sh" "{{ justfile_directory() }}/roles/custom"