start containers before pushing configurations when not using external volumes

This commit is contained in:
tom.chivert
2025-12-04 14:53:58 +01:00
parent 7218435b0a
commit c43a9f65e0
3 changed files with 47 additions and 6 deletions

View File

@@ -25,6 +25,21 @@
- gitlab-runner__etc_gitlab-runner - gitlab-runner__etc_gitlab-runner
tags: ['docker_gitlab-runner'] tags: ['docker_gitlab-runner']
- name: gitlab-runner | start service to create volumes
systemd:
name: docker-compose@gitlab-runner
state: started
when: not docker_services_external_volumes
tags: ['docker_gitlab-runner']
- name: gitlab-runner | wait for volumes to be created
wait_for:
path: /var/lib/docker/volumes/gitlab-runner__etc_gitlab-runner/_data
state: present
timeout: 20
when: not docker_services_external_volumes
tags: ['docker_gitlab-runner']
- name: gitlab-runner | configure config.toml - name: gitlab-runner | configure config.toml
copy: copy:
dest: '/var/lib/docker/volumes/gitlab-runner__etc_gitlab-runner/_data/config.toml' dest: '/var/lib/docker/volumes/gitlab-runner__etc_gitlab-runner/_data/config.toml'
@@ -58,7 +73,6 @@
{% if gitlab_runner_extra_hosts is defined %} {% if gitlab_runner_extra_hosts is defined %}
extra_hosts = [{% for host in gitlab_runner_extra_hosts %}"{{ host }}"{{ ", " if not loop.last else "" }}{% endfor %}] extra_hosts = [{% for host in gitlab_runner_extra_hosts %}"{{ host }}"{{ ", " if not loop.last else "" }}{% endfor %}]
{% endif %} {% endif %}
when: docker_services_external_volumes
notify: 'gitlab-runner-restart' notify: 'gitlab-runner-restart'
tags: ['docker_gitlab-runner'] tags: ['docker_gitlab-runner']

View File

@@ -32,12 +32,26 @@
register: 'register_docker_volume_gitlab_gitlab__run_secrets' register: 'register_docker_volume_gitlab_gitlab__run_secrets'
tags: ['docker_gitlab'] tags: ['docker_gitlab']
- name: gitlab | start service to create volumes
systemd:
name: docker-compose@gitlab
state: started
when: not docker_services_external_volumes
tags: ['docker_gitlab']
- name: gitlab | wait for volumes to be created
wait_for:
path: /var/lib/docker/volumes/gitlab__run_secrets/_data
state: present
timeout: 20
when: not docker_services_external_volumes
tags: ['docker_gitlab']
- name: 'gitlab | configure secret gitlab_root_password' - name: 'gitlab | configure secret gitlab_root_password'
copy: copy:
dest: '{{ register_docker_volume_gitlab_gitlab__run_secrets.volume.Mountpoint }}/gitlab_root_password' dest: '{{ register_docker_volume_gitlab_gitlab__run_secrets.volume.Mountpoint if docker_services_external_volumes else "/var/lib/docker/volumes/gitlab__run_secrets/_data" }}/gitlab_root_password'
mode: '0600' mode: '0600'
content: '{{ gitlab_root_password }}' content: '{{ gitlab_root_password }}'
when: docker_services_external_volumes
ignore_errors: '{{ ansible_check_mode }}' ignore_errors: '{{ ansible_check_mode }}'
tags: ['docker_gitlab'] tags: ['docker_gitlab']

View File

@@ -29,6 +29,21 @@
register: register_docker_volume_traefik__etc_traefik register: register_docker_volume_traefik__etc_traefik
tags: ['docker_traefik'] tags: ['docker_traefik']
- name: traefik | start service to create volumes
systemd:
name: docker-compose@traefik
state: started
when: not docker_services_external_volumes
tags: ['docker_traefik']
- name: traefik | wait for volumes to be created
wait_for:
path: /var/lib/docker/volumes/traefik__etc_traefik/_data
state: present
timeout: 20
when: not docker_services_external_volumes
tags: ['docker_traefik']
- name: traefik | copy configuration file - name: traefik | copy configuration file
template: template:
src: config/traefik/traefik.yml.j2 src: config/traefik/traefik.yml.j2
@@ -36,7 +51,6 @@
owner: root owner: root
group: root group: root
mode: 0644 mode: 0644
when: docker_services_external_volumes
notify: traefik-restart notify: traefik-restart
tags: ['docker_traefik'] tags: ['docker_traefik']
@@ -45,5 +59,4 @@
path: /var/lib/docker/volumes/traefik__etc_traefik/_data/dynamic path: /var/lib/docker/volumes/traefik__etc_traefik/_data/dynamic
state: directory state: directory
mode: '0755' mode: '0755'
when: docker_services_external_volumes tags: ['docker_traefik']
tags: ['docker_traefik']