Restore setup-org.yaml
This tasks file was removed when we rewrote the gitea management into python. Unfortunately our gitea rename project tasks rely on this tasks file to create new orgs if they are needed to rename a project. Restore this file so that we can rename projects in this manner. Note we move it into playbooks/ and rename it to gitea-rename-setup-org.yaml to make it clear that the gitea management role doesn't use this set of tasks, only the gitea project rename playbook does. Change-Id: I782f6e56cad18bdcbf9504d51af15caa950a5752
This commit is contained in:
parent
64e5f9235d
commit
f8bb46d810
56
playbooks/gitea-rename-setup-org.yaml
Normal file
56
playbooks/gitea-rename-setup-org.yaml
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
- name: Process org
|
||||||
|
debug:
|
||||||
|
msg: "Processing org {{ org }}"
|
||||||
|
- name: Create org
|
||||||
|
when: org not in gitea_orgs
|
||||||
|
uri:
|
||||||
|
url: "{{ gitea_url }}/api/v1/admin/users/root/orgs"
|
||||||
|
user: root
|
||||||
|
password: "{{ gitea_root_password }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 201
|
||||||
|
method: POST
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
username: "{{ org }}"
|
||||||
|
- name: Get org team list
|
||||||
|
uri:
|
||||||
|
url: "{{ gitea_url }}/api/v1/orgs/{{ org }}/teams"
|
||||||
|
user: root
|
||||||
|
password: "{{ gitea_root_password }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 200
|
||||||
|
register: gitea_org_team_list
|
||||||
|
- name: Get org owners
|
||||||
|
uri:
|
||||||
|
url: "{{ gitea_url }}/api/v1/teams/{{ (gitea_org_team_list.json | selectattr('name', 'equalto', 'Owners') | list)[0]['id'] }}/members"
|
||||||
|
user: root
|
||||||
|
password: "{{ gitea_root_password }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 200
|
||||||
|
register: gitea_org_members
|
||||||
|
- name: Add Gerrit user to org
|
||||||
|
when: "'gerrit' not in gitea_org_members.json | map(attribute='username')"
|
||||||
|
uri:
|
||||||
|
url: "{{ gitea_url }}/api/v1/teams/{{ (gitea_org_team_list.json | selectattr('name', 'equalto', 'Owners') | list)[0]['id'] }}/members/gerrit"
|
||||||
|
user: root
|
||||||
|
password: "{{ gitea_root_password }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 204
|
||||||
|
method: PUT
|
||||||
|
- name: Get org repo list
|
||||||
|
uri:
|
||||||
|
url: "{{ gitea_url }}/api/v1/orgs/{{ org }}/repos"
|
||||||
|
user: root
|
||||||
|
password: "{{ gitea_root_password }}"
|
||||||
|
force_basic_auth: true
|
||||||
|
validate_certs: false
|
||||||
|
status_code: 200
|
||||||
|
register: gitea_org_repo_list
|
||||||
|
- name: Parse org repo list
|
||||||
|
set_fact:
|
||||||
|
gitea_repos: "{{ gitea_org_repo_list.json | map(attribute='full_name') | list + gitea_repos | default([]) }}"
|
@ -22,7 +22,7 @@
|
|||||||
set_fact:
|
set_fact:
|
||||||
gitea_orgs: "{{ gitea_org_list.json | map(attribute='username') | list }}"
|
gitea_orgs: "{{ gitea_org_list.json | map(attribute='username') | list }}"
|
||||||
- name: "Make new gitea org"
|
- name: "Make new gitea org"
|
||||||
include_tasks: roles/gitea-git-repos/tasks/setup-org.yaml
|
include_tasks: gitea-rename-setup-org.yaml
|
||||||
vars:
|
vars:
|
||||||
org: "{{ neworg }}"
|
org: "{{ neworg }}"
|
||||||
- name: "Get repo {{ oldorg }}/{{ oldproj }}"
|
- name: "Get repo {{ oldorg }}/{{ oldproj }}"
|
||||||
|
Loading…
Reference in New Issue
Block a user