
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
40 lines
1.5 KiB
YAML
40 lines
1.5 KiB
YAML
- name: debug
|
|
debug:
|
|
msg: "{{ project }}"
|
|
- name: Parse project name
|
|
set_fact:
|
|
org: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\1') }}"
|
|
repo: "{{ project.project | regex_replace('^(.*)/(.*)$', '\\2') }}"
|
|
- name: Create repo
|
|
when: repo not in gitea_org_repos
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/org/{{ org }}/repos"
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 201
|
|
method: POST
|
|
body_format: json
|
|
body:
|
|
auto_init: false
|
|
description: "{{ project.description | default('') }}"
|
|
name: "{{ repo }}"
|
|
private: false
|
|
register: create_repo_result
|
|
- name: Get created repo id
|
|
when: "create_repo_result.json is defined"
|
|
set_fact:
|
|
repo_id: "{{ create_repo_result.json['id'] }}"
|
|
- name: Prepare sql query
|
|
when: "repo_id is defined"
|
|
set_fact:
|
|
sql_statement: |
|
|
start transaction;
|
|
delete from repo_unit where repo_id = {{ repo_id }} and `type` in (2, 3, 5, 7);
|
|
insert into repo_unit (repo_id, `type`, config, created_unix) values ({{ repo_id }}, 7, "{""ExternalTrackerURL"":""https://storyboard.openstack.org/#!/project/{{ org }}/{{ repo }}"",""ExternalTrackerFormat"":""https://storyboard.openstack.org/#!/story/{index}"",""ExternalTrackerStyle"":""""}", unix_timestamp());
|
|
commit;
|
|
- name: Adjust repo settings
|
|
when: "sql_statement is defined"
|
|
command: |
|
|
kubectl exec gitea-pxc-0 -c database -n gitea-db -- mysql gitea -e '{{ sql_statement }}'
|