-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgitlab-public.yml
executable file
·54 lines (47 loc) · 1.38 KB
/
gitlab-public.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/usr/bin/env ansible-playbook
---
- name: Create a pull mirror gitlab project
hosts: localhost
become: false
gather_facts: false
vars:
github_owner: buluma
gitlab_namespace: shadowwalker
vars_files:
- defaults/main.yml
- vars/main.yml
- vars/vault.yml
tasks:
- name: see if all variables are set
assert:
that:
- github_owner is defined
- role is defined
quiet: true
- name: Get a detailed list of owned GitLab projects
uri:
url: "https://gitlab.com/api/v4/projects?owned=true&search={{ role }}"
method: GET
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
return_content: true
register: gitlab_projects
- name: Pick project_ids from GitLab projects
set_fact:
gitlab_projects: "{{ gitlab_projects.json | selectattr('name', 'equalto', role) | list }}"
- name: pick a single project.
set_fact:
gitlab_project_id: "{{ gitlab_projects[0].id }}"
- name: Patch existing project to mirror
uri:
url: "https://gitlab.com/api/v4/projects/{{ gitlab_project_id }}"
method: PUT
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
body_format: json
body:
visibility: public
status_code:
- 200
register: create_project
changed_when: true