Admin deployment was very timing-dependent: If the server took a while to set it up, it would always error out while deploying. This commit adds sufficient grace-time into the admin request call before the error occurs which should avoid it in most deployments (unless the server is severely underpowered or over-taxed). Also fixes admin creation to avoid root usage in the container when it is not called for.
101 lines
3.4 KiB
YAML
101 lines
3.4 KiB
YAML
- 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 }}
|
|
user: git
|
|
become: true
|
|
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"
|
|
|
|
- name: Update ci upstream template
|
|
ansible.builtin.template:
|
|
src: upstream_ci.json.j2
|
|
dest: "{{ gitea_upstream_file_dir }}/upstream_ci.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"
|
|
|
|
# figure out if upstream id exists
|
|
- name: check {{ stack_name }}_ci upstream
|
|
community.docker.docker_container_exec:
|
|
container: "{{ caddy_container_id }}"
|
|
command: >
|
|
curl localhost:2019/id/{{ stack_name }}_ci_upstream/
|
|
changed_when: False
|
|
register: result
|
|
become: yes
|
|
listen: "update gitea upstream"
|
|
|
|
# upstream for ci already exists, patch it
|
|
- name: remove old {{ stack_name }}_ci upstream
|
|
community.docker.docker_container_exec:
|
|
container: "{{ caddy_container_id }}"
|
|
command: >
|
|
curl -X DELETE localhost:2019/id/{{ stack_name }}_ci_upstream/
|
|
become: yes
|
|
when: (result.stdout | from_json)['error'] is not defined
|
|
listen: "update gitea upstream"
|
|
#
|
|
# upstream for ci has to be created
|
|
- name: add {{ stack_name }}_ci 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_ci.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"
|
|
|