Merge "Omnibus rename repo playbook fixes"

This commit is contained in:
Zuul 2019-05-23 18:17:00 +00:00 committed by Gerrit Code Review
commit 509ec18dc9
2 changed files with 33 additions and 18 deletions

View File

@ -8,6 +8,10 @@
neworg: "{{ repo.new.split('/')[0] }}" neworg: "{{ repo.new.split('/')[0] }}"
oldproj: "{{ repo.old.split('/')[1] }}" oldproj: "{{ repo.old.split('/')[1] }}"
newproj: "{{ repo.new.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 }}" - name: "Get repo {{ oldorg }}/{{ oldproj }}"
uri: uri:
url: "{{ gitea_url }}/api/v1/repos/{{ oldorg }}/{{ oldproj }}" url: "{{ gitea_url }}/api/v1/repos/{{ oldorg }}/{{ oldproj }}"

View File

@ -9,35 +9,34 @@
shell: invoke-rc.d gerrit stop shell: invoke-rc.d gerrit stop
- name: Update account_project_watches in gerrit database - 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 }}" with_items: "{{ repos }}"
- name: Update changes in gerrit database - 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 }}" 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 - name: Rename git repos on gerrit
shell: mv {{ item[0] }}{{ item[1].old }}.git {{ item[0] }}{{ item[1].new }}.git shell: mv {{ item[0] }}{{ item[1].old }}.git {{ item[0] }}{{ item[1].new }}.git
with_nested: with_nested:
- [ '~gerrit2/review_site/git/', '/opt/lib/git/' ] - [ '~gerrit2/review_site/git/', '/opt/lib/git/' ]
- "{{ repos }}" - "{{ 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 - hosts: gitea
gather_facts: False gather_facts: False
vars: vars:
gitea_url: http://localhost:3000 gitea_url: https://localhost:3000
tasks: tasks:
- name: Get a CSRF token - name: Get a CSRF token
uri: uri:
@ -56,7 +55,7 @@
loop_control: loop_control:
loop_var: repo loop_var: repo
- hosts: storyboard.openstack.org - hosts: storyboard-dev
gather_facts: False gather_facts: False
remote_user: root remote_user: root
tasks: tasks:
@ -64,7 +63,20 @@
- include_vars: "{{ repolist }}" - include_vars: "{{ repolist }}"
- name: Rename projects in storyboard - 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 }}" with_items: "{{ repos }}"
- hosts: review - hosts: review
@ -82,7 +94,6 @@
remote_user: root remote_user: root
tasks: tasks:
# TODO: gerrit startup exceeds the timeout, so this task fails
- name: Start gerrit - name: Start gerrit
shell: invoke-rc.d gerrit start shell: invoke-rc.d gerrit start