mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2024-11-21 20:31:02 +01:00
Compare commits
6 Commits
d1b2d8e653
...
c2fe8a95c0
Author | SHA1 | Date | |
---|---|---|---|
c2fe8a95c0 | |||
647206b803 | |||
309e237f5c | |||
9fec9efcb1 | |||
7e694d71c0 | |||
6c0c8e0fc0 |
@ -2,18 +2,6 @@
|
||||
- name: "include tasks nginx-docker-proxy-domain.yml"
|
||||
include_tasks: nginx-docker-proxy-domain.yml
|
||||
|
||||
- name: register repository_directory_register
|
||||
stat:
|
||||
path: "{{repository_directory}}"
|
||||
register: repository_directory_register
|
||||
|
||||
- name: checkout repository
|
||||
ansible.builtin.shell: git checkout .
|
||||
become: true
|
||||
args:
|
||||
chdir: "{{repository_directory}}"
|
||||
when: repository_directory_register.stat.exists
|
||||
|
||||
- name: "backup docker-compose.yml if it exists"
|
||||
command: >
|
||||
mv "{{ docker_compose_file_path }}" "{{ docker_compose_backup_path }}"
|
||||
@ -21,6 +9,18 @@
|
||||
removes: "{{ docker_compose_file_path }}"
|
||||
become: true
|
||||
|
||||
- name: register directory
|
||||
stat:
|
||||
path: "{{docker_compose_instance_directory}}"
|
||||
register: docker_compose_instance_directory_register
|
||||
|
||||
- name: checkout repository
|
||||
ansible.builtin.shell: git checkout .
|
||||
become: true
|
||||
args:
|
||||
chdir: "{{docker_compose_instance_directory}}"
|
||||
when: docker_compose_instance_directory_register.stat.exists
|
||||
|
||||
- name: pull docker repository
|
||||
git:
|
||||
repo: "https://github.com/opf/openproject-deploy"
|
||||
|
@ -27,7 +27,8 @@ x-op-app: &app
|
||||
# set to true to enable the email receiving feature. See ./docker/cron for more options
|
||||
IMAP_ENABLED: "${IMAP_ENABLED:-false}"
|
||||
volumes:
|
||||
- "${OPDATA:-opdata}:/var/openproject/assets"
|
||||
- "${OPDATA}:/var/openproject/assets"
|
||||
- "${PGDATA}:/var/openproject/pgdata"
|
||||
|
||||
services:
|
||||
db:
|
||||
@ -35,9 +36,9 @@ services:
|
||||
<<: *restart_policy
|
||||
stop_grace_period: "3s"
|
||||
volumes:
|
||||
- "${PGDATA:-pgdata}:/var/lib/postgresql/data"
|
||||
- "${PGDATA}:/var/lib/postgresql/data"
|
||||
environment:
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD:-p4ssw0rd}
|
||||
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
|
||||
POSTGRES_DB: openproject
|
||||
networks:
|
||||
- backend
|
||||
@ -60,7 +61,10 @@ services:
|
||||
- web
|
||||
networks:
|
||||
- frontend
|
||||
|
||||
volumes:
|
||||
- "${OPDATA}:/var/openproject/assets"
|
||||
- "${PGDATA}:/var/openproject/pgdata"
|
||||
|
||||
web:
|
||||
<<: *app
|
||||
command: "./docker/prod/web"
|
||||
|
@ -17,6 +17,5 @@ DATABASE_URL="postgres://postgres:{{ openproject_database_password }}@db/openpro
|
||||
RAILS_MIN_THREADS=4
|
||||
RAILS_MAX_THREADS=16
|
||||
|
||||
# The following volumes are default
|
||||
PGDATA="pgdata"
|
||||
OPDATA="opdata"
|
@ -64,7 +64,8 @@ for filtered_failed_docker_compose_repository in filtered_failed_docker_compose_
|
||||
|
||||
if compose_file_path:
|
||||
print("Restarting unhealthy container in:", compose_file_path)
|
||||
print_bash(f'cd {os.path.dirname(compose_file_path)} && docker-compose restart')
|
||||
# Propably the cd is not necessary. But in rare cases it could be. To lazzy to test it now.
|
||||
print_bash(f'cd {os.path.dirname(compose_file_path)} && docker-compose -p "{filtered_failed_docker_compose_repository}" restart')
|
||||
else:
|
||||
print("Error: Docker Compose file not found for:", filtered_failed_docker_compose_repository)
|
||||
errors += 1
|
||||
|
@ -1,20 +1,30 @@
|
||||
#!/bin/sh
|
||||
docker_ps_grep_unhealthy="$(docker ps --filter health=unhealthy --format '{{.Names}}')"
|
||||
docker_ps_grep_exited="$(docker ps --filter status=exited --format '{{.Names}}')"
|
||||
docker_ps_grep_exited="$(docker ps --filter status=exited --format '{{.ID}}')"
|
||||
|
||||
exitcode=0
|
||||
if [ ! -z "$docker_ps_grep_unhealthy" ]
|
||||
then
|
||||
|
||||
if [ -n "$docker_ps_grep_unhealthy" ]; then
|
||||
echo "Some docker containers are unhealthy: $docker_ps_grep_unhealthy"
|
||||
exitcode=1
|
||||
fi
|
||||
if [ ! -z "$docker_ps_grep_exited" ]
|
||||
then
|
||||
echo "Some docker containers exited: $docker_ps_grep_exited"
|
||||
exitcode=2
|
||||
|
||||
if [ -n "$docker_ps_grep_exited" ]; then
|
||||
for container_id in $docker_ps_grep_exited
|
||||
do
|
||||
container_exit_code="$(docker inspect "$container_id" --format='{{.State.ExitCode}}')"
|
||||
container_name="$(docker inspect "$container_id" --format='{{.Name}}')"
|
||||
container_name="${container_name#/}" # Entfernt das führende '/'
|
||||
if [ "$container_exit_code" -ne "0" ]; then
|
||||
echo "Container $container_name exited with code $container_exit_code"
|
||||
exitcode=2
|
||||
fi
|
||||
done
|
||||
fi
|
||||
if [ "$exitcode" -ne "0" ]
|
||||
then
|
||||
|
||||
if [ "$exitcode" -ne "0" ]; then
|
||||
exit $exitcode
|
||||
fi
|
||||
|
||||
echo "All docker containers are healthy."
|
||||
exit
|
||||
exit
|
||||
|
@ -10,7 +10,7 @@ anonymous_volumes=$(docker volume ls --format "{{.Name}}" | grep -E '^[a-f0-9]{6
|
||||
|
||||
if [ -z "$anonymous_volumes" ]; then
|
||||
echo "No anonymous volumes found."
|
||||
exit $status
|
||||
exit
|
||||
fi
|
||||
|
||||
echo "Anonymous volumes found:"
|
||||
@ -41,4 +41,12 @@ for volume in $anonymous_volumes; do
|
||||
done
|
||||
done
|
||||
|
||||
# Additional warning for dangling volumes
|
||||
dangling_volumes=$(docker volume ls -f dangling=true --format "{{.Name}}")
|
||||
if [ -n "$dangling_volumes" ]; then
|
||||
status=2
|
||||
echo "The following dangling volumes were found:"
|
||||
echo "$dangling_volumes"
|
||||
fi
|
||||
|
||||
exit $status
|
||||
|
Loading…
Reference in New Issue
Block a user