From 209ef36490e1402f7ba41a57d38bcbefc2650581 Mon Sep 17 00:00:00 2001 From: Ser5 Date: Sun, 26 Oct 2025 11:12:28 +0300 Subject: [PATCH] Added "just inventory" and "make inventory" commands --- Makefile | 17 +++++++++++++++++ docs/quick-start.md | 15 ++++++++++++++- justfile | 20 ++++++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 9ac77bb0760..5322530dc48 100644 --- a/Makefile +++ b/Makefile @@ -4,9 +4,26 @@ .PHONY: roles lint +VARS_DIR := inventory/host_vars/$(domain) +VARS_FILE := inventory/host_vars/$(domain)/vars.yml +HOSTS_FILE := inventory/hosts + help: ## Show this help. @grep -F -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\\$$//' | sed -e 's/##//' +inventory: ## Initialize inventory files + @mkdir -p "$(VARS_DIR)" + @cp examples/vars.yml "$(VARS_FILE)" + @cp examples/hosts inventory/hosts + @sed -i 's/^matrix_domain:.*/matrix_domain: $(domain)/' "$(VARS_FILE)" + @PASSWORD=`openssl rand -base64 64 | head -c 64`; \ + sed -i "s#^matrix_homeserver_generic_secret_key:.*#matrix_homeserver_generic_secret_key: '$$PASSWORD'#" "$(VARS_FILE)" + @sed -i 's/^matrix\.example\.com/$(domain)/' "$(HOSTS_FILE)" + @sed -i 's/ansible_host=<[^>]\+>/ansible_host=$(ip)/' "$(HOSTS_FILE)" + @echo "Check and configure your files at:" + @echo $(VARS_FILE) + @echo $(HOSTS_FILE) + roles: ## Pull roles rm -rf roles/galaxy ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force diff --git a/docs/quick-start.md b/docs/quick-start.md index ae9328f0a65..28bb57d003a 100644 --- a/docs/quick-start.md +++ b/docs/quick-start.md @@ -89,7 +89,20 @@ To install Matrix services with this playbook, you would at least need 2 configu For your convenience, we have prepared example files of them ([`vars.yml`](../examples/vars.yml) and [`hosts`](../examples/hosts)). -To start quickly based on these example files, go into the `matrix-docker-ansible-deploy` directory and follow the instructions below: +To start quickly based on these example files, go into the `matrix-docker-ansible-deploy` directory and follow the instructions below. + + +If you have `just` installed, replace the **domain** and "**1.2.3.4**" with you own and run: +```sh +just matrix.yourdomain.com 1.2.3.4 +``` + +If you have `make`, run: +```sh +make domain=matrix.yourdomain.com ip=1.2.3.4 +``` + +Otherwise you may copy the files manually: 1. Create a directory to hold your configuration: `mkdir -p inventory/host_vars/matrix.example.com` where `example.com` is your "base domain" 2. Copy the sample configuration file: `cp examples/vars.yml inventory/host_vars/matrix.example.com/vars.yml` diff --git a/justfile b/justfile index b44ac9b4f1e..61b0a165be6 100644 --- a/justfile +++ b/justfile @@ -8,6 +8,26 @@ default: @{{ just_executable() }} --list --justfile "{{ justfile() }}" +# Initialize inventory files +inventory domain ip: + #!/usr/bin/env sh + VARS_DIR="inventory/host_vars/{{ domain }}" + VARS_FILE="inventory/host_vars/{{ domain }}/vars.yml" + HOSTS_FILE="inventory/hosts" + + mkdir -p "$VARS_DIR" + cp examples/vars.yml "$VARS_FILE" + cp examples/hosts inventory/hosts + sed -i 's/^matrix_domain:.*/matrix_domain: {{ domain }}/' "$VARS_FILE" + PASSWORD=`openssl rand -base64 64 | head -c 64`; \ + sed -i "s#^matrix_homeserver_generic_secret_key:.*#matrix_homeserver_generic_secret_key: '$PASSWORD'#" "$VARS_FILE" + sed -i 's/^matrix\.example\.com/{{ domain }}/' "$HOSTS_FILE" + sed -i 's/ansible_host=<[^>]\+>/ansible_host={{ ip }}/' "$HOSTS_FILE" + echo "Check and configure your files at:" + echo $VARS_FILE + echo $HOSTS_FILE + + # Pulls external Ansible roles roles: #!/usr/bin/env sh