87 lines
2.5 KiB
YAML
87 lines
2.5 KiB
YAML
---
|
|
# Gitea deployment tasks
|
|
- name: Create Gitea data directories
|
|
file:
|
|
path: "{{ item }}"
|
|
state: directory
|
|
mode: '0755'
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
loop:
|
|
- "{{ gitea_data_path }}"
|
|
- "{{ gitea_config_path }}"
|
|
- "{{ gitea_git_path }}"
|
|
|
|
- name: Create Docker Compose file for Gitea
|
|
template:
|
|
src: gitea-docker-compose.yml.j2
|
|
dest: "/opt/gitea/docker-compose.yml"
|
|
mode: '0644'
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
|
|
- name: Create Gitea startup script
|
|
template:
|
|
src: start-gitea.sh.j2
|
|
dest: "/opt/gitea/start-gitea.sh"
|
|
mode: '0755'
|
|
owner: "{{ ansible_user }}"
|
|
group: "{{ ansible_user }}"
|
|
|
|
- name: Check if docker-compose is available
|
|
command: docker-compose --version
|
|
register: docker_compose_check
|
|
failed_when: false
|
|
changed_when: false
|
|
when: not ansible_check_mode
|
|
|
|
- name: Stop existing Gitea container if running
|
|
shell: docker-compose -f /opt/gitea/docker-compose.yml down
|
|
args:
|
|
chdir: /opt/gitea
|
|
ignore_errors: yes
|
|
when: not ansible_check_mode and docker_compose_check.rc == 0
|
|
|
|
- name: Start Gitea container
|
|
shell: docker-compose -f /opt/gitea/docker-compose.yml up -d
|
|
args:
|
|
chdir: /opt/gitea
|
|
when: not ansible_check_mode and docker_compose_check.rc == 0
|
|
|
|
- name: Display warning if docker-compose not available
|
|
debug:
|
|
msg: "WARNING: docker-compose not found. Please run with --tags docker first to install Docker and Docker Compose."
|
|
when: not ansible_check_mode and docker_compose_check.rc != 0
|
|
|
|
- name: Wait for Gitea to be ready
|
|
uri:
|
|
url: "http://localhost:{{ gitea_port }}"
|
|
method: GET
|
|
status_code: 200
|
|
register: gitea_ready
|
|
retries: 30
|
|
delay: 10
|
|
until: gitea_ready.status == 200
|
|
when: not ansible_check_mode
|
|
|
|
- name: Display Gitea status
|
|
debug:
|
|
msg: "Gitea is running and accessible on http://localhost:{{ gitea_port }}"
|
|
|
|
- name: Create systemd service for Gitea
|
|
template:
|
|
src: gitea.service.j2
|
|
dest: "/etc/systemd/system/gitea.service"
|
|
mode: '0644'
|
|
|
|
- name: Reload systemd daemon
|
|
systemd:
|
|
daemon_reload: yes
|
|
|
|
- name: Enable Gitea service
|
|
systemd:
|
|
name: gitea
|
|
enabled: yes
|
|
state: started
|
|
when: not ansible_check_mode
|