Fix gitea admin setup, Add healthcheck

Added healthcheck to gitea database contaier.

Fixed initial admin setup checks - uses correct in-container user and
fixed fail checks.
This commit is contained in:
Marty Oehme 2022-01-22 10:48:31 +01:00
parent 06bb34891e
commit 1e0643352d
Signed by: Marty
GPG key ID: B7538B8F50A1C800
2 changed files with 12 additions and 4 deletions

View file

@ -10,6 +10,7 @@
loop_var: distribution
when: gitea_use_ci == True
# TODO only generate when no existing (check with docker inspect?)
- name: Generate agent key
ansible.builtin.shell: openssl rand -hex 32
register: gitea_woodpecker_agent_secret
@ -105,13 +106,14 @@
- name: Look for existing admin user
community.docker.docker_container_exec:
container: "{{ gitea_app_container_name['stdout'] }}"
user: git
command: >
gitea admin user list --admin
become: yes
until: "'connection refused' not in gitea_admin_list and 'Failed to run app' not in gitea_admin_list"
retries: 5
until: "'connection refused' not in gitea_admin_list['stdout'] and 'Failed to run app' not in gitea_admin_list['stdout']"
retries: 10
delay: 10
changed_when: gitea_admin_list['stdout_lines'] | length <= 1
failed_when: gitea_admin_list['rc'] == 1 and gitea_admin_list['attempts'] >= 5
changed_when: gitea_admin_list['stdout_lines'] | length <= 1 and 'Username' in gitea_admin_list['stdout']
failed_when: (gitea_admin_list['rc'] == 1 and gitea_admin_list['attempts'] >= 5) or 'Gitea is not supposed to be run as root' in gitea_admin_list['stdout']
register: gitea_admin_list
notify: "no admin user"

View file

@ -47,6 +47,12 @@ services:
db:
image: postgres:13
healthcheck:
test: ["CMD", "pg_isready", "-q", "-U", "{{ gitea_db_username }}"]
interval: 1m
timeout: 10s
retries: 3
start_period: 1m
volumes:
- db:/var/lib/postgresql/data
networks: