17b996d2e1
We need to create repos in gitea before we do so in Gerrit (because they will not be replicated correctly if Gerrit pushes to a repo that doesn't already exist in gitea). Therefore, we need to add gitea to the repo creation playbook so that we create new repos based on the contents of project-config. This updates the gitea sync-repos playbook to use that instead of fetching the list from Gerrit. It also improves the gitea bootstrap playbook to wait for the load balancer to come online. Change-Id: I783a2eed497a830aaf71ad95dea03594774ff6d7
52 lines
1.6 KiB
YAML
52 lines
1.6 KiB
YAML
- name: Process org
|
|
debug:
|
|
msg: "Processing org {{ org }}"
|
|
- name: Create org
|
|
when: org not in gitea_orgs
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/admin/users/root/orgs"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 201
|
|
method: POST
|
|
body_format: json
|
|
body:
|
|
username: "{{ org }}"
|
|
- name: Get org team list
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/orgs/{{ org }}/teams"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 200
|
|
register: gitea_org_team_list
|
|
- name: Get org owners
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/teams/{{ (gitea_org_team_list.json | selectattr('name', 'equalto', 'Owners') | list)[0]['id'] }}/members"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 200
|
|
register: gitea_org_members
|
|
- name: Add Gerrit user to org
|
|
when: "'gerrit' not in gitea_org_members.json | map(attribute='username')"
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/teams/{{ (gitea_org_team_list.json | selectattr('name', 'equalto', 'Owners') | list)[0]['id'] }}/members/gerrit"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 204
|
|
method: PUT
|
|
- name: Get org repo list
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/orgs/{{ org }}/repos"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 200
|
|
register: gitea_org_repo_list
|
|
- name: Parse org repo list
|
|
set_fact:
|
|
gitea_org_repos: "{{ gitea_org_repo_list.json | map(attribute='name') | list }}"
|