mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2025-05-18 18:50:32 +02:00
Added journalctl logging for docker up's and execute portfolio just once condition
This commit is contained in:
parent
ae48aebcd7
commit
39b312b997
@ -17,3 +17,19 @@ watch -n 2 "docker compose ps -a"
|
|||||||
```bash
|
```bash
|
||||||
docker inspect --format='{{json .State.Health}}' <container_id>
|
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.
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,9 +10,12 @@
|
|||||||
|
|
||||||
# default setup for docker compose files
|
# default setup for docker compose files
|
||||||
- name: docker compose project setup
|
- name: docker compose project setup
|
||||||
command:
|
shell: >
|
||||||
cmd: "docker-compose -p {{application_id}} up -d --force-recreate --remove-orphans"
|
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 }}"
|
chdir: "{{ docker_compose.directories.instance }}"
|
||||||
|
executable: /bin/bash
|
||||||
environment:
|
environment:
|
||||||
COMPOSE_HTTP_TIMEOUT: 600
|
COMPOSE_HTTP_TIMEOUT: 600
|
||||||
DOCKER_CLIENT_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
|
# 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
|
# for performance reasons it's not recommended to use this if there is no build tag specified
|
||||||
- name: docker compose project build and setup
|
- name: docker compose project build and setup
|
||||||
command:
|
shell: >
|
||||||
cmd: "docker-compose -p {{application_id}} up -d --force-recreate --build --remove-orphans"
|
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 }}"
|
chdir: "{{ docker_compose.directories.instance }}"
|
||||||
|
executable: /bin/bash
|
||||||
environment:
|
environment:
|
||||||
COMPOSE_HTTP_TIMEOUT: 600
|
COMPOSE_HTTP_TIMEOUT: 600
|
||||||
DOCKER_CLIENT_TIMEOUT: 600
|
DOCKER_CLIENT_TIMEOUT: 600
|
||||||
|
@ -15,3 +15,13 @@ To reinitialize the container execute:
|
|||||||
```bash
|
```bash
|
||||||
docker network connect discourse_default central-postgres && /opt/docker/discourse/services/discourse_repository/launcher rebuild discourse_application
|
docker network connect discourse_default central-postgres && /opt/docker/discourse/services/discourse_repository/launcher rebuild discourse_application
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### 🔍 Logging with `journalctl`
|
||||||
|
|
||||||
|
All build 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 rebuild-discourse -f
|
||||||
|
```
|
||||||
|
@ -17,7 +17,10 @@
|
|||||||
listen: recreate discourse
|
listen: recreate discourse
|
||||||
|
|
||||||
- name: rebuild discourse
|
- name: rebuild discourse
|
||||||
command:
|
shell: >
|
||||||
cmd: "./launcher rebuild {{applications[application_id].container}}"
|
./launcher rebuild {{applications[application_id].container}}
|
||||||
|
2>&1 | tee >(systemd-cat -t rebuild-{{ application_id }})
|
||||||
|
args:
|
||||||
|
executable: /bin/bash
|
||||||
chdir: "{{docker_repository_directory }}"
|
chdir: "{{docker_repository_directory }}"
|
||||||
listen: recreate discourse
|
listen: recreate discourse
|
@ -2,6 +2,7 @@
|
|||||||
- name: "include docker-compose role"
|
- name: "include docker-compose role"
|
||||||
include_role:
|
include_role:
|
||||||
name: docker-compose
|
name: docker-compose
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: "include role nginx-domain-setup for {{application_id}}"
|
- name: "include role nginx-domain-setup for {{application_id}}"
|
||||||
include_role:
|
include_role:
|
||||||
@ -9,10 +10,12 @@
|
|||||||
vars:
|
vars:
|
||||||
domain: "{{ domains[application_id] }}"
|
domain: "{{ domains[application_id] }}"
|
||||||
http_port: "{{ ports.localhost.http[application_id] }}"
|
http_port: "{{ ports.localhost.http[application_id] }}"
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: "include role docker-repository-setup for {{application_id}}"
|
- name: "include role docker-repository-setup for {{application_id}}"
|
||||||
include_role:
|
include_role:
|
||||||
name: docker-repository-setup
|
name: docker-repository-setup
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: "Check if host-specific config.yaml exists in {{ config_inventory_path }}"
|
- name: "Check if host-specific config.yaml exists in {{ config_inventory_path }}"
|
||||||
stat:
|
stat:
|
||||||
@ -20,18 +23,22 @@
|
|||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
become: false
|
become: false
|
||||||
register: config_file
|
register: config_file
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Load menu categories
|
- name: Load menu categories
|
||||||
include_vars:
|
include_vars:
|
||||||
file: "menu_categories.yml"
|
file: "menu_categories.yml"
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Load docker cards
|
- name: Load docker cards
|
||||||
set_fact:
|
set_fact:
|
||||||
portfolio_cards: "{{ lookup('docker_cards', 'roles') }}"
|
portfolio_cards: "{{ lookup('docker_cards', 'roles') }}"
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Group docker cards
|
- name: Group docker cards
|
||||||
set_fact:
|
set_fact:
|
||||||
portfolio_menu_data: "{{ lookup('docker_cards_grouped', portfolio_cards, portfolio_menu_categories) }}"
|
portfolio_menu_data: "{{ lookup('docker_cards_grouped', portfolio_cards, portfolio_menu_categories) }}"
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Debug portfolio data
|
- name: Debug portfolio data
|
||||||
debug:
|
debug:
|
||||||
@ -39,24 +46,36 @@
|
|||||||
portfolio_cards: "{{ portfolio_cards }}"
|
portfolio_cards: "{{ portfolio_cards }}"
|
||||||
portfolio_menu_categories: "{{ portfolio_menu_categories}}"
|
portfolio_menu_categories: "{{ portfolio_menu_categories}}"
|
||||||
portfolio_menu_data: "{{ portfolio_menu_data }}"
|
portfolio_menu_data: "{{ portfolio_menu_data }}"
|
||||||
when: enable_debug | bool
|
when:
|
||||||
|
- enable_debug | bool
|
||||||
|
- run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Copy host-specific config.yaml if it exists
|
- name: Copy host-specific config.yaml if it exists
|
||||||
template:
|
template:
|
||||||
src: "{{ config_inventory_path }}"
|
src: "{{ config_inventory_path }}"
|
||||||
dest: "{{docker_repository_path}}/app/config.yaml"
|
dest: "{{docker_repository_path}}/app/config.yaml"
|
||||||
notify: docker compose project setup
|
notify: docker compose project setup
|
||||||
when: config_file.stat.exists
|
when:
|
||||||
|
- config_file.stat.exists
|
||||||
|
- run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: Copy default config.yaml from the role template if host-specific file does not exist
|
- name: Copy default config.yaml from the role template if host-specific file does not exist
|
||||||
template:
|
template:
|
||||||
src: "config.yaml.j2"
|
src: "config.yaml.j2"
|
||||||
dest: "{{docker_repository_path}}/app/config.yaml"
|
dest: "{{docker_repository_path}}/app/config.yaml"
|
||||||
notify: docker compose project setup
|
notify: docker compose project setup
|
||||||
when: not config_file.stat.exists
|
when:
|
||||||
|
- not config_file.stat.exists
|
||||||
|
- run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
- name: add docker-compose.yml
|
- name: add docker-compose.yml
|
||||||
template:
|
template:
|
||||||
src: docker-compose.yml.j2
|
src: docker-compose.yml.j2
|
||||||
dest: "{docker_compose.directories.instance}}docker-compose.yml"
|
dest: "{docker_compose.directories.instance}}docker-compose.yml"
|
||||||
notify: docker compose project setup
|
notify: docker compose project setup
|
||||||
|
when: run_once_docker_portfolio is not defined
|
||||||
|
|
||||||
|
- name: run the portfolio tasks once
|
||||||
|
set_fact:
|
||||||
|
run_once_docker_portfolio: true
|
||||||
|
when: run_once_docker_portfolio is not defined
|
Loading…
x
Reference in New Issue
Block a user