mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-08-29 15:06:26 +02:00
Added journalctl logging for docker up's and execute portfolio just once condition
This commit is contained in:
@@ -16,4 +16,20 @@ watch -n 2 "docker compose ps -a"
|
||||
|
||||
```bash
|
||||
docker inspect --format='{{json .State.Health}}' <container_id>
|
||||
```
|
||||
```
|
||||
|
||||
### 🔍 Logging with `journalctl`
|
||||
|
||||
All Docker Compose actions triggered by this role are logged to the system journal using `systemd-cat`. Output is simultaneously shown in the terminal and available via `journalctl`.
|
||||
|
||||
To view logs for a specific application:
|
||||
|
||||
```bash
|
||||
journalctl -t docker-compose-<application_id> -f
|
||||
```
|
||||
|
||||
Replace `<application_id>` with the actual project name (e.g. `discourse`, `nextcloud`, etc.).
|
||||
|
||||
This enables persistent and searchable logs for all container setups and rebuilds.
|
||||
|
||||
|
||||
|
@@ -4,15 +4,18 @@
|
||||
# https://github.com/ansible/ansible/issues/10244
|
||||
#- name: shut down docker compose project
|
||||
# command:
|
||||
# cmd: docker-compose -p "{{application_id}}" down
|
||||
# cmd: docker-compose -p "{{ application_id }}" down
|
||||
# listen: docker compose project setup
|
||||
# when: mode_reset | bool
|
||||
|
||||
# default setup for docker compose files
|
||||
- name: docker compose project setup
|
||||
command:
|
||||
cmd: "docker-compose -p {{application_id}} up -d --force-recreate --remove-orphans"
|
||||
chdir: "{{docker_compose.directories.instance}}"
|
||||
shell: >
|
||||
docker-compose -p {{ application_id }} up -d --force-recreate --remove-orphans
|
||||
2>&1 | tee >(systemd-cat -t docker-compose-{{ application_id }})
|
||||
args:
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
||||
@@ -21,9 +24,12 @@
|
||||
# it's necessary to rebuild when a build in the docker compose files is defined
|
||||
# for performance reasons it's not recommended to use this if there is no build tag specified
|
||||
- name: docker compose project build and setup
|
||||
command:
|
||||
cmd: "docker-compose -p {{application_id}} up -d --force-recreate --build --remove-orphans"
|
||||
chdir: "{{docker_compose.directories.instance}}"
|
||||
shell: >
|
||||
docker-compose -p {{ application_id }} up -d --force-recreate --build --remove-orphans
|
||||
2>&1 | tee >(systemd-cat -t docker-compose-{{ application_id }})
|
||||
args:
|
||||
chdir: "{{ docker_compose.directories.instance }}"
|
||||
executable: /bin/bash
|
||||
environment:
|
||||
COMPOSE_HTTP_TIMEOUT: 600
|
||||
DOCKER_CLIENT_TIMEOUT: 600
|
||||
|
Reference in New Issue
Block a user