diff --git a/tasks/main.yaml b/tasks/main.yaml index 9304775..6442b03 100644 --- a/tasks/main.yaml +++ b/tasks/main.yaml @@ -12,13 +12,20 @@ name: git register: git_user +- name: Create Gitea + file: + path: "/opt/gitea" + state: directory + owner: root + mode: 0755 + - name: Create Data Directory file: path: "/opt/gitea/data" state: directory owner: "{{ git_user.uid }}" group: "{{ git_user.group }}" - mode: '0755' + mode: 0755 - name: Create Config Directory file: @@ -26,7 +33,7 @@ state: directory owner: "{{ git_user.uid }}" group: "{{ git_user.group }}" - mode: '0755' + mode: 0755 - name: Start Docker Daemon systemd: @@ -38,25 +45,17 @@ ansible.builtin.template: src: environment.env.j2 dest: "/opt/gitea/environment.env" - owner: "{{ git_user.name }}" - mode: '600' + owner: root + mode: 0644 + +- name: Upload docker-compose.yaml + ansible.builtin.template: + src: docker-compose.yaml.j2 + dest: /opt/gitea/docker-compose.yaml + owner: root + mode: 0644 - name: Create Gitea container - community.docker.docker_container: - name: gitea - image: "gitea:{{ gitea_vars['version'] }}-rootless" - comparisons: - image: strict - volumes: strict - env: strict - restart_policy: unless-stopped - volumes: - - /opt/gitea/data:/var/lib/gitea" - - /opt/gitea/config:/etc/gitea" - - /etc/timezone:/etc/timezone:ro - - /etc/localtime:/etc/localtime:ro - ports: - - "3000:3000" - - "22:2222" - user: "{{ git_user.uid }}:{{ git_user.group }}" - env_file: "/opt/gitea/environment.env" + community.docker.docker_compose: + project_src: /opt/gitea + state: present diff --git a/templates/docker-compose.yaml.j2 b/templates/docker-compose.yaml.j2 new file mode 100644 index 0000000..b1b413f --- /dev/null +++ b/templates/docker-compose.yaml.j2 @@ -0,0 +1,16 @@ +version: "3.8" + +services: + server: + image: gitea/gitea:{{ gitea_vars['version'] }}-rootless + restart: always + volumes: + - ./data:/var/lib/gitea + - ./config:/etc/gitea + - /etc/timezone:/etc/timezone:ro + - /etc/localtime:/etc/localtime:ro + ports: + - "3000:3000" + - "22:2222" + env_file: ./environment.env + user: "{{ git_user.uid }}:{{ git_user.group }}" \ No newline at end of file