From 2ad6bd87c7c798d4c082e171b33bb1f046353b06 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Tue, 22 Nov 2022 09:09:11 +0200 Subject: [PATCH] Determine matrix_architecture automatically --- docs/alternative-architectures.md | 20 ++++++------------- docs/self-building.md | 4 ++-- roles/custom/matrix-base/defaults/main.yml | 2 +- .../custom/matrix-base/tasks/sanity_check.yml | 1 + 4 files changed, 10 insertions(+), 17 deletions(-) diff --git a/docs/alternative-architectures.md b/docs/alternative-architectures.md index c8097b60..0865de1f 100644 --- a/docs/alternative-architectures.md +++ b/docs/alternative-architectures.md @@ -1,26 +1,18 @@ # Alternative architectures -As stated in the [Prerequisites](prerequisites.md), currently only `x86_64` is fully supported. However, it is possible to set the target architecture, and some tools can be built on the host or other measures can be used. +As stated in the [Prerequisites](prerequisites.md), currently only `amd64` (`x86_64`) is fully supported. -To that end add the following variable to your `vars.yml` file (see [Configuring playbook](configuring-playbook.md)): +The playbook automatically determines the target server's architecture (the `matrix_architecture` variable) to be one of the following: -```yaml -matrix_architecture: -``` - -Currently supported architectures are the following: -- `amd64` (the default) -- `arm64` +- `amd64` (`x86_64`) - `arm32` +- `arm64` -so for the Raspberry Pi, the following should be in your `vars.yml` file: +Some tools and container images can be built on the host or other measures can be used to install on that architecture. -```yaml -matrix_architecture: "arm32" -``` ## Implementation details For `amd64`, prebuilt container images (see the [container images we use](container-images.md)) are used for all components (except [Hydrogen](configuring-playbook-client-hydrogen.md), which goes through self-building). -For other architectures, components which have a prebuilt image make use of it. If the component is not available for the specific architecture, [self-building](self-building.md) will be used. Not all components support self-building though, so your mileage may vary. +For other architecture (`arm64`, `arm32`), components which have a prebuilt image make use of it. If the component is not available for the specific architecture, [self-building](self-building.md) will be used. Not all components support self-building though, so your mileage may vary. diff --git a/docs/self-building.md b/docs/self-building.md index 3351a1f8..ad29fc2d 100644 --- a/docs/self-building.md +++ b/docs/self-building.md @@ -6,11 +6,11 @@ The playbook supports self-building of various components, which don't have a co For other architectures (e.g. `arm32`, `arm64`), ready-made container images are used when available. If there's no ready-made image for a specific component and said component supports self-building, an image will be built on the host. Building images like this takes more time and resources (some build tools need to get installed by the playbook to assist building). -To make use of self-building, you don't need to do anything besides change your architecture variable (e.g. `matrix_architecture: arm64`). If a component has an image for the specified architecture, the playbook will use it directly. If not, it will build the image on the server itself. +To make use of self-building, you don't need to do anything. If a component has an image for the specified architecture, the playbook will use it directly. If not, it will build the image on the server itself. Note that **not all components support self-building yet**. -List of roles where self-building the Docker image is currently possible: +Possibly outdated list of roles where self-building the Docker image is currently possible: - `matrix-synapse` - `matrix-synapse-admin` - `matrix-client-element` diff --git a/roles/custom/matrix-base/defaults/main.yml b/roles/custom/matrix-base/defaults/main.yml index f0d86c70..534db078 100644 --- a/roles/custom/matrix-base/defaults/main.yml +++ b/roles/custom/matrix-base/defaults/main.yml @@ -86,7 +86,7 @@ matrix_federation_public_port: 8448 # Recognized values by us are 'amd64', 'arm32' and 'arm64'. # Not all architectures support all services, so your experience (on non-amd64) may vary. # See docs/alternative-architectures.md -matrix_architecture: amd64 +matrix_architecture: "{{ 'amd64' if ansible_architecture == 'x86_64' else ('arm64' if ansible_architecture == 'aarch64' else ('arm32' if ansible_architecture.startswith('armv') else '')) }}" # The architecture for Debian packages. # See: https://wiki.debian.org/SupportedArchitectures diff --git a/roles/custom/matrix-base/tasks/sanity_check.yml b/roles/custom/matrix-base/tasks/sanity_check.yml index f825e19e..2644d4cf 100644 --- a/roles/custom/matrix-base/tasks/sanity_check.yml +++ b/roles/custom/matrix-base/tasks/sanity_check.yml @@ -40,6 +40,7 @@ - {'var': matrix_server_fqn_element, 'value': "{{ matrix_server_fqn_element | default('') }}"} - {'var': matrix_homeserver_container_url, 'value': "{{ matrix_homeserver_container_url | default('') }}"} - {'var': matrix_homeserver_container_federation_url, 'value': "{{ matrix_homeserver_container_federation_url | default('') }}"} + - {'var': matrix_architecture, 'value': "{{ matrix_architecture | default('') }}"} when: "item.value is none or item.value == ''" - name: Fail if uppercase domain used