Add add-inventory-host command for bootstrapping the inventory

Running `just add-inventory-host example.com 1.2.3.4` (or
`make add-inventory-host domain=example.com ip=1.2.3.4`) adds a new
host to the inventory, creating inventory/hosts and
inventory/host_vars/matrix.DOMAIN/vars.yml from the example files,
with strong secrets generated automatically.

Existing configuration is never overwritten. The command refuses to
run if the host is already in the inventory, so it can also be used
for adding more hosts later.

Based on the idea proposed in
https://github.com/spantaleev/matrix-docker-ansible-deploy/pull/4682 by @Ser5

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
Slavi Pantaleev
2026-07-12 16:08:09 +03:00
parent 0f7f60372f
commit 80c2624454
4 changed files with 145 additions and 2 deletions
+4
View File
@@ -13,6 +13,10 @@ prek_home := env("PREK_HOME", justfile_directory() / "var/prek")
default:
@{{ just_executable() }} --list --justfile "{{ justfile() }}"
# Adds a new host to the inventory, creating the inventory files if necessary (e.g. `just add-inventory-host example.com 1.2.3.4`)
add-inventory-host domain server_address:
@{{ justfile_directory() }}/bin/add-inventory-host.sh {{ quote(domain) }} {{ quote(server_address) }}
# Pulls external Ansible roles
roles:
#!/usr/bin/env sh