8ef8d900e2
During the great opendev git migration we ran into a number of issues with out existing renaming playbook. This attempts to capture the lot of them and includes: - Fixing mysql configuration file paths - Set mysql defaults file arg before database name - Use storyboard group instead of hostname - Run storyboard db update against storyboard-dev too - Create the new org dirs on review.opendev.org before moving repos - Create new orgs in gitea before moving repos - Use https when talking to gitea instead of http (to avoid problems with redirects) Details at our etherpad here: https://etherpad.openstack.org/p/the-great-opendev-git-migration Change-Id: I5f8ed779b3f1186c2ec540730f6b4f5f51a5016c
56 lines
1.9 KiB
YAML
56 lines
1.9 KiB
YAML
# Note, if both the org and project names change, this script will
|
|
# perform the org transfer first, followed by the project name change.
|
|
# If there is already a project in the new org with the old name, it
|
|
# will fail.
|
|
- name: "Parse repo names for {{ repo.old }} -> {{ repo.new }}"
|
|
set_fact:
|
|
oldorg: "{{ repo.old.split('/')[0] }}"
|
|
neworg: "{{ repo.new.split('/')[0] }}"
|
|
oldproj: "{{ repo.old.split('/')[1] }}"
|
|
newproj: "{{ repo.new.split('/')[1] }}"
|
|
- name: "Make new gitea org"
|
|
include_tasks: roles/gitea-git-repos/tasks/setup-org.yaml
|
|
var:
|
|
org: "{{ neworg }}"
|
|
- name: "Get repo {{ oldorg }}/{{ oldproj }}"
|
|
uri:
|
|
url: "{{ gitea_url }}/api/v1/repos/{{ oldorg }}/{{ oldproj }}"
|
|
validate_certs: false
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
register: gitea_repo
|
|
- name: "Transfer repo ownership from {{ oldorg }}/{{ oldproj }} to {{ neworg }}/{{ oldproj }}"
|
|
when: "oldorg != neworg"
|
|
uri:
|
|
url: "{{ gitea_url }}/{{ oldorg }}/{{ oldproj }}/settings"
|
|
validate_certs: false
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 302
|
|
method: POST
|
|
body_format: form-urlencoded
|
|
body:
|
|
_csrf: "{{ gitea_token }}"
|
|
action: transfer
|
|
repo_name: "{{ oldproj }}"
|
|
new_owner_name: "{{ neworg }}"
|
|
- name: "Update repo name from {{ neworg }}/{{ oldproj }} to {{ neworg }}/{{ newproj }}"
|
|
when: "oldproj != newproj"
|
|
uri:
|
|
url: "{{ gitea_url }}/{{ neworg }}/{{ oldproj }}/settings"
|
|
validate_certs: false
|
|
user: root
|
|
password: "{{ gitea_root_password }}"
|
|
force_basic_auth: true
|
|
status_code: 302
|
|
method: POST
|
|
body_format: form-urlencoded
|
|
body:
|
|
_csrf: "{{ gitea_token }}"
|
|
action: update
|
|
repo_name: "{{ newproj }}"
|
|
description: "{{ gitea_repo.json.description }}"
|
|
website: "{{ gitea_repo.json.website }}"
|