diff --git a/playbooks/roles/gitea/tasks/main.yaml b/playbooks/roles/gitea/tasks/main.yaml index 6c19bdb140..8226637555 100644 --- a/playbooks/roles/gitea/tasks/main.yaml +++ b/playbooks/roles/gitea/tasks/main.yaml @@ -34,13 +34,42 @@ shell: cmd: docker-compose pull chdir: /etc/gitea-docker/ -- name: Run docker-compose up - shell: - cmd: docker-compose up -d --timeout 60 - chdir: /etc/gitea-docker/ -- name: Run docker prune to cleanup unneeded images - shell: - cmd: docker image prune -f + register: docker_compose_pull + +- name: Stop/Start gitea safely for Gerrit replication + when: "'Downloaded newer image' in docker_compose_pull.stdout" + block: + - name: Run docker-compose stop + shell: + cmd: docker-compose stop --timeout 60 + chdir: /etc/gitea-docker/ + - name: Run docker-compose up mariadb gitea-web + shell: + cmd: docker-compose up -d --timeout 60 mariadb gitea-web + chdir: /etc/gitea-docker/ + + # We wait here for the main gitea service to start before starting + # the ssh service. This is friendly to gerrit replication. + - name: Wait until the web service is sufficiently up to start ssh + uri: + url: "https://localhost:3000/api/v1/users/root" + validate_certs: false + status_code: 200, 404 + register: root_user_check + delay: 1 + retries: 300 + until: root_user_check and root_user_check.status in (200, 404) + + - name: Run docker-compose up gitea-ssh + shell: + cmd: docker-compose up -d --timeout 60 gitea-ssh + chdir: /etc/gitea-docker/ + - name: Run docker prune to cleanup unneeded images + shell: + cmd: docker image prune -f + +# User management outside of service bringup to avoid confusion between +# the two stages. - name: Check if root user exists uri: url: "https://localhost:3000/api/v1/users/root" diff --git a/playbooks/roles/gitea/templates/docker-compose.yaml.j2 b/playbooks/roles/gitea/templates/docker-compose.yaml.j2 index 0ae57b8276..1dab97f1ff 100644 --- a/playbooks/roles/gitea/templates/docker-compose.yaml.j2 +++ b/playbooks/roles/gitea/templates/docker-compose.yaml.j2 @@ -35,6 +35,7 @@ services: gitea-ssh: depends_on: - mariadb + - gitea-web environment: - SSH_LISTEN_PORT=222 image: docker.io/opendevorg/gitea-openssh