--- - name: Create GitLab directories file: path: "{{ item }}" state: directory owner: root group: root mode: '0755' loop: - "{{ gitlab_config_dir }}" - "{{ gitlab_logs_dir }}" - "{{ gitlab_data_dir }}" - "{{ gitlab_backup_dir }}" - name: Deploy Docker Compose file for GitLab template: src: docker-compose.gitlab.yml.j2 dest: "{{ gitlab_base_dir }}/docker-compose.yml" mode: '0644' - name: Check if GitLab container is running shell: docker ps --filter "name=gitlab" --format "{{ '{{.Names}}' }}" register: gitlab_container_check changed_when: false - name: Start GitLab container with Docker Compose command: cmd: docker compose up -d chdir: "{{ gitlab_base_dir }}" when: "'gitlab' not in gitlab_container_check.stdout" - name: Restart GitLab if configuration changed command: cmd: docker compose up -d --force-recreate chdir: "{{ gitlab_base_dir }}" when: - "'gitlab' in gitlab_container_check.stdout" - gitlab_container_check is changed - name: Wait for GitLab to be ready wait_for: host: "{{ ansible_host }}" port: "{{ gitlab_http_port }}" timeout: 600 state: started delay: 30 - name: Check GitLab status uri: url: "http://{{ ansible_host }}:{{ gitlab_http_port }}/users/sign_in" status_code: 200 timeout: 30 register: gitlab_status until: gitlab_status.status == 200 retries: 5 delay: 30 - name: Show GitLab status debug: msg: "GitLab is running and accessible at http://{{ ansible_host }}:{{ gitlab_http_port }}" when: gitlab_status.status == 200