Omnibus rename repo playbook fixes

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
This commit is contained in:
Clark Boylan 2019-04-24 08:37:36 -07:00
parent 6d48f0561e
commit 8ef8d900e2
2 changed files with 33 additions and 18 deletions

View File

@ -8,6 +8,10 @@
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 }}"

View File

@ -9,35 +9,34 @@
shell: invoke-rc.d gerrit stop
- name: Update account_project_watches in gerrit database
shell: echo 'update account_project_watches set project_name = "{{ item.new }}" where project_name = "{{ item.old }}";' | mysql reviewdb --defaults-file=/root/.gerrit_db.cfg
shell: echo 'update account_project_watches set project_name = "{{ item.new }}" where project_name = "{{ item.old }}";' | mysql --defaults-file=/root/.gerrit_db.cnf reviewdb
with_items: "{{ repos }}"
- name: Update changes in gerrit database
shell: echo 'update changes set dest_project_name = "{{ item.new }}", created_on = created_on where dest_project_name = "{{ item.old }}";' | mysql reviewdb --defaults-file=/root/.gerrit_db.cfg
shell: echo 'update changes set dest_project_name = "{{ item.new }}", created_on = created_on where dest_project_name = "{{ item.old }}";' | mysql --defaults-file=/root/.gerrit_db.cnf reviewdb
with_items: "{{ repos }}"
- name: Make organization dir
file:
state: directory
path: "{{ (item[0] + item[1].new) | dirname }}"
group: gerrit2
owner: gerrit2
mode: 0755
with_nested:
- [ '~gerrit2/review_site/git/', '/opt/lib/git/' ]
- "{{ repos }}"
- name: Rename git repos on gerrit
shell: mv {{ item[0] }}{{ item[1].old }}.git {{ item[0] }}{{ item[1].new }}.git
with_nested:
- [ '~gerrit2/review_site/git/', '/opt/lib/git/' ]
- "{{ repos }}"
- hosts: 'git0*'
gather_facts: False
tasks:
- include_vars: "{{ repolist }}"
- name: Rename git repos on git farm
shell: mv {{ item[0] }}{{ item[1].old }}.git {{ item[0] }}{{ item[1].new }}.git
with_nested:
- [ '/var/lib/git/' ]
- "{{ repos }}"
- hosts: gitea
gather_facts: False
vars:
gitea_url: http://localhost:3000
gitea_url: https://localhost:3000
tasks:
- name: Get a CSRF token
uri:
@ -56,7 +55,7 @@
loop_control:
loop_var: repo
- hosts: storyboard.openstack.org
- hosts: storyboard-dev
gather_facts: False
remote_user: root
tasks:
@ -64,7 +63,20 @@
- include_vars: "{{ repolist }}"
- name: Rename projects in storyboard
shell: echo 'update projects set name="{{ item.new }}" where name="{{ item.old }}";' | mysql --defaults-file=/root/.storyboard_db.cnf storyboard
shell: echo 'update projects set name="{{ item.new }}" where name="{{ item.old }}";' | mysql --defaults-file=/etc/mysql/debian.cnf storyboard
with_items: "{{ repos }}"
# We don't want to be blocked by errors on the dev server.
ignore_errors: yes
- hosts: storyboard
gather_facts: False
remote_user: root
tasks:
- include_vars: "{{ repolist }}"
- name: Rename projects in storyboard
shell: echo 'update projects set name="{{ item.new }}" where name="{{ item.old }}";' | mysql --defaults-file=/etc/mysql/debian.cnf storyboard
with_items: "{{ repos }}"
- hosts: review
@ -82,7 +94,6 @@
remote_user: root
tasks:
# TODO: gerrit startup exceeds the timeout, so this task fails
- name: Start gerrit
shell: invoke-rc.d gerrit start