Merge "Use project-config when syncing gitea repos"
This commit is contained in:
commit
534c8d1e75
@ -1,6 +1,5 @@
|
||||
- hosts: localhost
|
||||
tasks:
|
||||
# Deploy the service
|
||||
- name: Set up gitea namespace
|
||||
k8s:
|
||||
state: present
|
||||
@ -30,15 +29,15 @@
|
||||
k8s:
|
||||
state: present
|
||||
definition: "{{ lookup('template', 'k8s/service.yaml') | from_yaml }}"
|
||||
|
||||
# Bootstrap
|
||||
# TODO: wait until service is up
|
||||
- name: Get service IP
|
||||
k8s:
|
||||
namespace: gitea
|
||||
kind: Service
|
||||
name: gitea-service
|
||||
register: gitea_service
|
||||
until: gitea_service.result.status.loadBalancer and gitea_service.result.status.loadBalancer.ingress and gitea_service.result.status.loadBalancer.ingress | length > 0 and gitea_service.result.status.loadBalancer.ingress[0].ip
|
||||
delay: 1
|
||||
retries: 300
|
||||
- name: Set service url fact
|
||||
set_fact:
|
||||
gitea_url: "http://{{ gitea_service.result.status.loadBalancer.ingress[0].ip }}"
|
||||
|
@ -49,8 +49,3 @@
|
||||
- name: Parse org repo list
|
||||
set_fact:
|
||||
gitea_org_repos: "{{ gitea_org_repo_list.json | map(attribute='name') | list }}"
|
||||
- name: Create repos in org
|
||||
loop: "{{ (gerrit_projects.keys() | map('regex_search', '^' + org + '/.*') | select | map('regex_replace', '^.*/', '') | list) }}"
|
||||
loop_control:
|
||||
loop_var: repo
|
||||
include_tasks: 'setup-repo.yaml'
|
||||
|
@ -1,6 +1,10 @@
|
||||
- name: debug
|
||||
debug:
|
||||
msg: "{{ gerrit_projects[org+'/'+repo] }}"
|
||||
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:
|
||||
@ -13,7 +17,7 @@
|
||||
body_format: json
|
||||
body:
|
||||
auto_init: false
|
||||
description: "{{ gerrit_projects[org+'/'+repo]['description'] | default('') }}"
|
||||
description: "{{ project.description | default('') }}"
|
||||
name: "{{ repo }}"
|
||||
private: false
|
||||
register: create_repo_result
|
||||
@ -32,4 +36,4 @@
|
||||
- name: Adjust repo settings
|
||||
when: "sql_statement is defined"
|
||||
command: |
|
||||
/home/corvus/opendev/kubectl exec gitea-pxc-0 -c database -n gitea-db -- mysql gitea -e '{{ sql_statement }}'
|
||||
kubectl exec gitea-pxc-0 -c database -n gitea-db -- mysql gitea -e '{{ sql_statement }}'
|
||||
|
@ -1,19 +1,20 @@
|
||||
- hosts: localhost
|
||||
vars:
|
||||
gitea_url: http://38.108.68.66
|
||||
gitea_url: http://38.108.68.64
|
||||
project_config_ref: master
|
||||
project_config_dest: /tmp/project_config
|
||||
tasks:
|
||||
- name: Clone project-config
|
||||
git:
|
||||
repo: https://git.openstack.org/openstack-infra/project-config
|
||||
dest: "{{ project_config_dest }}"
|
||||
version: "{{ project_config_ref }}"
|
||||
- name: Get Gerrit project list
|
||||
uri:
|
||||
url: "https://review.openstack.org/projects/"
|
||||
status_code: 200
|
||||
return_content: true
|
||||
register: gerrit_project_list
|
||||
- name: Parse Gerrit project list
|
||||
set_fact:
|
||||
gerrit_projects: "{{ gerrit_project_list.content[4:] | from_json }}"
|
||||
gerrit_projects: "{{ lookup('file', project_config_dest + '/gerrit/projects.yaml') | from_yaml }}"
|
||||
- name: Parse Gerrit org list
|
||||
set_fact:
|
||||
gerrit_orgs: "{{ gerrit_projects.keys() | map('regex_search', '^(.*?)/') | list | unique | select | map('regex_replace', '/', '') | list }}"
|
||||
gerrit_orgs: "{{ gerrit_projects | map(attribute='project') | map('regex_search', '^(.*?)/') | list | unique | select | map('regex_replace', '/', '') | list }}"
|
||||
- name: debug
|
||||
debug:
|
||||
msg: "{{ gerrit_orgs }}"
|
||||
@ -34,3 +35,8 @@
|
||||
loop_control:
|
||||
loop_var: org
|
||||
include_tasks: 'setup-org.yaml'
|
||||
- name: Create repos
|
||||
loop: "{{ gerrit_projects }}"
|
||||
loop_control:
|
||||
loop_var: project
|
||||
include_tasks: 'setup-repo.yaml'
|
||||
|
Loading…
Reference in New Issue
Block a user