Move from gitea to forgejo
Moved all variables over; moved git passthrough script to new location and naming scheme; moved settings and mentions of gitea name; switched ci woodpecker instance to use forgejo instead of gitea.
This commit is contained in:
parent
b6e30811dc
commit
648f49a847
8 changed files with 125 additions and 121 deletions
|
|
@ -8,48 +8,55 @@
|
|||
- "{{ ansible_os_family }}.yml"
|
||||
loop_control:
|
||||
loop_var: distribution
|
||||
when: gitea_use_ci == True
|
||||
when: forgejo_use_ci == True
|
||||
|
||||
# TODO only generate when no existing (check with docker inspect?)
|
||||
- name: Generate agent key
|
||||
ansible.builtin.shell: openssl rand -hex 32
|
||||
register: gitea_woodpecker_agent_secret
|
||||
when: gitea_use_ci == True
|
||||
register: forgejo_woodpecker_agent_secret
|
||||
when: forgejo_use_ci == True
|
||||
|
||||
- name: Set agent key
|
||||
ansible.builtin.set_fact:
|
||||
gitea_woodpecker_agent_secret: "{{ gitea_woodpecker_agent_secret.stdout }}"
|
||||
when: gitea_woodpecker_agent_secret.stdout is not undefined and not None
|
||||
forgejo_woodpecker_agent_secret: "{{ forgejo_woodpecker_agent_secret.stdout }}"
|
||||
when: forgejo_woodpecker_agent_secret.stdout is not undefined and not None
|
||||
|
||||
## Prepare gitea
|
||||
## Prepare forgejo
|
||||
- name: Ensure git user exists with ssh key
|
||||
ansible.builtin.user:
|
||||
name: "{{ gitea_git_username }}"
|
||||
name: "{{ forgejo_git_username }}"
|
||||
generate_ssh_key: yes
|
||||
ssh_key_type: rsa
|
||||
ssh_key_bits: 4096
|
||||
ssh_key_comment: "Gitea Host Key"
|
||||
ssh_key_comment: "Forgejo Host Key"
|
||||
become: true
|
||||
register: git_user
|
||||
|
||||
- name: Ensure git passthrough command directory exists
|
||||
ansible.builtin.file:
|
||||
path: "/app/gitea/"
|
||||
path: "/app/forgejo/"
|
||||
state: directory
|
||||
mode: '0770'
|
||||
owner: "{{ git_user['uid'] }}"
|
||||
group: "{{ git_user['group'] }}"
|
||||
become: true
|
||||
|
||||
- name: Save git passthrough command in right location
|
||||
- name: Passthrough git command is in right location
|
||||
ansible.builtin.copy:
|
||||
src: gitea
|
||||
dest: "/app/gitea/gitea"
|
||||
src: forgejo
|
||||
dest: "/app/forgejo/forgejo"
|
||||
owner: "{{ git_user['uid'] }}"
|
||||
group: "{{ git_user['group'] }}"
|
||||
mode: '0750'
|
||||
become: true
|
||||
|
||||
- name: Host machine forgejo command points to passthrough command
|
||||
ansible.builtin.file:
|
||||
state: link
|
||||
src: "/app/forgejo/forgejo"
|
||||
dest: "/usr/local/bin/forgejo"
|
||||
become: true
|
||||
|
||||
- name: Fetch keyfile
|
||||
fetch:
|
||||
src: "{{ git_user['home'] }}/.ssh/id_rsa.pub"
|
||||
|
|
@ -70,7 +77,7 @@
|
|||
state: absent
|
||||
delegate_to: localhost
|
||||
|
||||
## install gitea container
|
||||
## install forgejo container
|
||||
- name: Check upstream status
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ caddy_container_id }}"
|
||||
|
|
@ -79,9 +86,9 @@
|
|||
register: result
|
||||
changed_when: (result.stdout | from_json) != (lookup('template', 'upstream.json.j2') | from_yaml)
|
||||
become: true
|
||||
notify: "update gitea upstream"
|
||||
notify: "update forgejo upstream"
|
||||
|
||||
- name: Deploy gitea to swarm
|
||||
- name: Deploy forgejo to swarm
|
||||
community.general.docker_stack:
|
||||
name: "{{ stack_name }}"
|
||||
state: present
|
||||
|
|
@ -91,35 +98,35 @@
|
|||
become: true
|
||||
tags:
|
||||
- docker-swarm
|
||||
register: gitea_deployment
|
||||
notify: "update gitea upstream"
|
||||
register: forgejo_deployment
|
||||
notify: "update forgejo upstream"
|
||||
|
||||
- name: Wait a minute for gitea to become healthy
|
||||
- name: Wait a minute for forgejo to become healthy
|
||||
wait_for:
|
||||
timeout: 55
|
||||
delegate_to: localhost
|
||||
when: gitea_deployment is changed
|
||||
when: forgejo_deployment is changed
|
||||
|
||||
- name: Get app container info
|
||||
ansible.builtin.command:
|
||||
cmd: docker ps -q -f name={{ stack_name }}_app
|
||||
become: true
|
||||
until: gitea_app_container_name['rc'] | default('') == 0 and gitea_app_container_name['stdout'] | length >= 1
|
||||
until: forgejo_app_container_name['rc'] | default('') == 0 and forgejo_app_container_name['stdout'] | length >= 1
|
||||
retries: 10
|
||||
delay: 10
|
||||
changed_when: False
|
||||
register: gitea_app_container_name
|
||||
register: forgejo_app_container_name
|
||||
|
||||
- name: Look for existing admin user
|
||||
community.docker.docker_container_exec:
|
||||
container: "{{ gitea_app_container_name['stdout'] }}"
|
||||
container: "{{ forgejo_app_container_name['stdout'] }}"
|
||||
user: git
|
||||
command: >
|
||||
gitea admin user list --admin
|
||||
until: gitea_admin_list is defined and gitea_admin_list['rc'] | default('') == 0
|
||||
forgejo admin user list --admin
|
||||
until: forgejo_admin_list is defined and forgejo_admin_list['rc'] | default('') == 0
|
||||
retries: 15
|
||||
delay: 20
|
||||
become: true
|
||||
register: gitea_admin_list
|
||||
changed_when: gitea_admin_list['stdout_lines'] | length <= 1 and 'Username' in gitea_admin_list['stdout']
|
||||
register: forgejo_admin_list
|
||||
changed_when: forgejo_admin_list['stdout_lines'] | length <= 1 and 'Username' in forgejo_admin_list['stdout']
|
||||
notify: "no admin user"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue