Explorar el Código

Added "just inventory" and "make inventory" commands

pull/4682/head
Ser5 hace 4 meses
padre
commit
209ef36490
Se han modificado 3 ficheros con 51 adiciones y 1 borrados
  1. +17
    -0
      Makefile
  2. +14
    -1
      docs/quick-start.md
  3. +20
    -0
      justfile

+ 17
- 0
Makefile Ver fichero

@@ -4,9 +4,26 @@


.PHONY: roles lint .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. help: ## Show this help.
@grep -F -h "##" $(MAKEFILE_LIST) | grep -v grep | sed -e 's/\\$$//' | sed -e 's/##//' @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 roles: ## Pull roles
rm -rf roles/galaxy rm -rf roles/galaxy
ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force ansible-galaxy install -r requirements.yml -p roles/galaxy/ --force


+ 14
- 1
docs/quick-start.md Ver fichero

@@ -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)). 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" 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` 2. Copy the sample configuration file: `cp examples/vars.yml inventory/host_vars/matrix.example.com/vars.yml`


+ 20
- 0
justfile Ver fichero

@@ -8,6 +8,26 @@
default: default:
@{{ just_executable() }} --list --justfile "{{ justfile() }}" @{{ 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 # Pulls external Ansible roles
roles: roles:
#!/usr/bin/env sh #!/usr/bin/env sh


Cargando…
Cancelar
Guardar