ansible-nas/roles/gitea/tasks/main.yml

74 lines
2.5 KiB
YAML

---
- name: Start Gitea
block:
- name: Create Gitea Directories
ansible.builtin.file:
path: "{{ item }}"
state: directory
recurse: yes
with_items:
- "{{ gitea_data_directory }}/gitea"
- "{{ gitea_data_directory }}/mysql"
- name: Create MySQL container for Gitea
community.docker.docker_container:
name: "{{ gitea_mysql_container_name }}"
image: "{{ gitea_mysql_image_name }}:{{ gitea_mysql_image_version }}"
pull: true
volumes:
- "{{ gitea_data_directory }}/mysql:/var/lib/mysql:rw"
env:
MYSQL_DATABASE: "gitea"
MYSQL_USER: "gitea"
MYSQL_PASSWORD: "gitea"
MYSQL_ROOT_PASSWORD: "gitea"
restart_policy: unless-stopped
memory: "{{ gitea_mysql_memory }}"
- name: Create Gitea container
community.docker.docker_container:
name: "{{ gitea_container_name }}"
image: "{{ gitea_image_name }}:{{ gitea_image_version }}"
pull: true
volumes:
- "{{ gitea_data_directory }}/gitea:/data:rw"
ports:
- "{{ gitea_port_http }}:3000"
- "{{ gitea_port_ssh }}:22"
links:
- gitea-mysql:db
env:
DB_TYPE: "mysql"
DB_HOST: "db:3306"
DB_NAME: "gitea"
DB_USER: "gitea"
DB_PASSWD: "gitea"
RUN_MODE: "prod"
SSH_DOMAIN: "{{ ansible_nas_hostname }}"
SSH_PORT: "22"
ROOT_URL: "http://{{ gitea_hostname }}:{{ gitea_port_http }}/"
USER_UID: "1000"
USER_GID: "1000"
restart_policy: unless-stopped
memory: "{{ gitea_memory }}"
labels:
traefik.enable: "{{ gitea_available_externally | string }}"
traefik.http.routers.gitea.rule: "Host(`{{ gitea_hostname }}.{{ ansible_nas_domain }}`)"
traefik.http.routers.gitea.tls.certresolver: "letsencrypt"
traefik.http.routers.gitea.tls.domains[0].main: "{{ ansible_nas_domain }}"
traefik.http.routers.gitea.tls.domains[0].sans: "*.{{ ansible_nas_domain }}"
traefik.http.services.gitea.loadbalancer.server.port: "3000"
when: gitea_enabled is true
- name: Stop Gitea
block:
- name: Stop Gitea
community.docker.docker_container:
name: "{{ gitea_container_name }}"
state: absent
- name: Stop Gitea Mysql
community.docker.docker_container:
name: "{{ gitea_mysql_container_name }}"
state: absent
when: gitea_enabled is false