Add gitea role

Added base gitea docker setup role.

Adds automatic unattended setup with default admin account and optional
email notification setup.
This commit is contained in:
Marty Oehme 2021-12-08 09:16:32 +01:00
parent 12a3fa1e6f
commit 3a5b5680cf
Signed by: Marty
GPG key ID: B7538B8F50A1C800
10 changed files with 360 additions and 0 deletions

View file

@ -0,0 +1,62 @@
- name: Add admin user
community.docker.docker_container_exec:
container: "{{ gitea_app_container_name['stdout'] }}"
command: >
gitea admin user create --admin --username {{ gitea_app_admin_username }} --password {{ gitea_app_admin_password }} --email {{ gitea_app_admin_email }}
become: yes
listen: "no admin user"
## Register reverse proxy
- name: Ensure upstream directory exists
ansible.builtin.file:
path: "{{ gitea_upstream_file_dir }}"
state: directory
mode: '0755'
become: yes
listen: "update gitea upstream"
- name: Update upstream template
ansible.builtin.template:
src: upstream.json.j2
dest: "{{ gitea_upstream_file_dir }}/upstream.json"
mode: '0600'
become: yes
listen: "update gitea upstream"
# figure out if upstream id exists
- name: check {{ stack_name }} upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl localhost:2019/id/{{ stack_name }}_upstream/
changed_when: False
register: result
become: yes
listen: "update gitea upstream"
# upstream already exists, patch it
- name: remove old {{ stack_name }} upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X DELETE localhost:2019/id/{{ stack_name }}_upstream/
become: yes
when: (result.stdout | from_json)['error'] is not defined
listen: "update gitea upstream"
# upstream has to be created
- name: add {{ stack_name }} upstream
community.docker.docker_container_exec:
container: "{{ caddy_container_id }}"
command: >
curl -X POST -H "Content-Type: application/json" -d @{{ gitea_upstream_file_dir }}/upstream.json localhost:2019/config/apps/http/servers/{{ (gitea_use_https == True) | ternary(caddy_https_server_name, caddy_http_server_name) }}/routes/0/
become: yes
listen: "update gitea upstream"
- name: Ensure upstream directory is gone again
ansible.builtin.file:
path: "{{ gitea_upstream_file_dir }}"
state: absent
become: yes
listen: "update gitea upstream"