Sweeper.
This commit is contained in:
parent
4f25fb8469
commit
fe79fff48f
|
|
@ -6,7 +6,7 @@
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
namespace: robertdebock
|
namespace: robertdebock-iac
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- vars/main.yml
|
- vars/main.yml
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,45 @@
|
||||||
|
#!/usr/bin/env ansible-playbook
|
||||||
|
---
|
||||||
|
- name: Import repository into gitlab project
|
||||||
|
hosts: localhost
|
||||||
|
become: no
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
github_owner: robertdebock
|
||||||
|
gitlab_namespace: robertdebock-iac
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- defaults/main.yml
|
||||||
|
- vars/main.yml
|
||||||
|
- vars/vault.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: see if all variables are set
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- gitlab_namespace is defined
|
||||||
|
- github_owner is defined
|
||||||
|
- role is defined
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Get GitHub repo information
|
||||||
|
uri:
|
||||||
|
url: "https://api.github.com/repos/{{ github_owner }}/{{ role }}"
|
||||||
|
headers:
|
||||||
|
Authorization: "Bearer {{ github_token }}"
|
||||||
|
register: github_repo
|
||||||
|
|
||||||
|
- name: Import repository
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/import/github"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
personal_access_token: "{{ github_token }}"
|
||||||
|
repo_id: "{{ github_repo.json.id }}"
|
||||||
|
target_namespace: "{{ gitlab_namespace }}"
|
||||||
|
status_code:
|
||||||
|
- 201
|
||||||
|
|
@ -0,0 +1,62 @@
|
||||||
|
#!/usr/bin/env ansible-playbook
|
||||||
|
---
|
||||||
|
- name: Kick off a pipeline for a GitLab project
|
||||||
|
hosts: localhost
|
||||||
|
become: no
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
gitlab_namespace: robertdebock-iac
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- defaults/main.yml
|
||||||
|
- vars/main.yml
|
||||||
|
- vars/vault.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: see if all variables are set
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- gitlab_namespace is defined
|
||||||
|
- role is defined
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Get GitLab project number
|
||||||
|
uri:
|
||||||
|
url: https://gitlab.com/api/v4/projects/{{ gitlab_namespace }}%2F{{ role }}
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
register: gitlab_project_details
|
||||||
|
|
||||||
|
- name: Create pipeline trigger
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/projects/{{ gitlab_project_details.json.id }}/triggers"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
body_format: form-urlencoded
|
||||||
|
body:
|
||||||
|
description: "Ansible"
|
||||||
|
status_code:
|
||||||
|
- 201
|
||||||
|
register: pipeline_trigger
|
||||||
|
|
||||||
|
- name: Trigger pipeline
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/projects/{{ gitlab_project_details.json.id }}/trigger/pipeline"
|
||||||
|
method: POST
|
||||||
|
body_format: form-urlencoded
|
||||||
|
body:
|
||||||
|
token: "{{ pipeline_trigger.json.token }}"
|
||||||
|
ref: master
|
||||||
|
status_code:
|
||||||
|
- 201
|
||||||
|
|
||||||
|
- name: Delete pipeline trigger
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/projects/{{ gitlab_project_details.json.id }}/triggers/{{ pipeline_trigger.json.id }}"
|
||||||
|
method: DELETE
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
status_code:
|
||||||
|
- 204
|
||||||
|
|
@ -0,0 +1,73 @@
|
||||||
|
#!/usr/bin/env ansible-playbook
|
||||||
|
---
|
||||||
|
- name: Create a pull mirror gitlab project
|
||||||
|
hosts: localhost
|
||||||
|
become: no
|
||||||
|
gather_facts: no
|
||||||
|
|
||||||
|
vars:
|
||||||
|
github_owner: robertdebock
|
||||||
|
gitlab_namespace: robertdebock-iac
|
||||||
|
|
||||||
|
vars_files:
|
||||||
|
- defaults/main.yml
|
||||||
|
- vars/main.yml
|
||||||
|
- vars/vault.yml
|
||||||
|
|
||||||
|
tasks:
|
||||||
|
- name: see if all variables are set
|
||||||
|
assert:
|
||||||
|
that:
|
||||||
|
- gitlab_namespace is defined
|
||||||
|
- github_owner is defined
|
||||||
|
- role is defined
|
||||||
|
quiet: yes
|
||||||
|
|
||||||
|
- name: Get GitHub repo information
|
||||||
|
uri:
|
||||||
|
url: "https://api.github.com/repos/{{ github_owner }}/{{ role }}"
|
||||||
|
headers:
|
||||||
|
Authorization: "Bearer {{ github_token }}"
|
||||||
|
register: github_repo
|
||||||
|
|
||||||
|
# - name: Show shit
|
||||||
|
# debug:
|
||||||
|
# msg: "{{ github_repo.json }}"
|
||||||
|
|
||||||
|
- name: Get GitLab namespace_id
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/namespaces"
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
search: "{{ gitlab_namespace }}"
|
||||||
|
register: gitlab_namespace
|
||||||
|
|
||||||
|
# - name: Show shit
|
||||||
|
# debug:
|
||||||
|
# msg: "{{ gitlab_namespace.json }}"
|
||||||
|
|
||||||
|
- name: Create a project that pulls from GitHub
|
||||||
|
uri:
|
||||||
|
url: "https://gitlab.com/api/v4/projects"
|
||||||
|
method: POST
|
||||||
|
headers:
|
||||||
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
|
body_format: json
|
||||||
|
body:
|
||||||
|
name: "{{ github_repo.json.name }}"
|
||||||
|
description: "{{ github_repo.json.description }}"
|
||||||
|
# TODO: Should the `path` include the namespace:
|
||||||
|
path: "{{ github_repo.json.name }}"
|
||||||
|
namespace_id: 59906445
|
||||||
|
import_url: "{{ github_repo.json.clone_url }}"
|
||||||
|
mirror: true
|
||||||
|
mirror_triggers_builds: true
|
||||||
|
status_code:
|
||||||
|
- 201
|
||||||
|
register: gitlab_project
|
||||||
|
|
||||||
|
# - name: Show shit
|
||||||
|
# debug:
|
||||||
|
# msg: "{{ gitlab_project }}"
|
||||||
56
gitlab.yml
56
gitlab.yml
|
|
@ -6,7 +6,7 @@
|
||||||
gather_facts: no
|
gather_facts: no
|
||||||
|
|
||||||
vars:
|
vars:
|
||||||
namespace: robertdebock
|
namespace: robertdebock-iac
|
||||||
|
|
||||||
vars_files:
|
vars_files:
|
||||||
- defaults/main.yml
|
- defaults/main.yml
|
||||||
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
- name: urlencode path
|
- name: urlencode path
|
||||||
set_fact:
|
set_fact:
|
||||||
encoded_path: "{{ namespace + '%2F' + role }}"
|
encoded_path: "{{ namespace + '%2F' + 'ansible-role-' + role }}"
|
||||||
|
|
||||||
- name: place variable
|
- name: place variable
|
||||||
block:
|
block:
|
||||||
|
|
@ -76,20 +76,20 @@
|
||||||
loop_control:
|
loop_control:
|
||||||
label: "{{ item.id }}"
|
label: "{{ item.id }}"
|
||||||
|
|
||||||
# - name: create a new pipeline schedule
|
- name: create a new pipeline schedule
|
||||||
# uri:
|
uri:
|
||||||
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
|
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
|
||||||
# method: POST
|
method: POST
|
||||||
# body_format: json
|
body_format: json
|
||||||
# status_code:
|
status_code:
|
||||||
# - 201
|
- 201
|
||||||
# headers:
|
headers:
|
||||||
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
# body:
|
body:
|
||||||
# description: "Monthly test"
|
description: "Monthly test"
|
||||||
# ref: master
|
ref: master
|
||||||
# cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
|
cron: "{{ letter_minute_mapping[role[:1]] | default('13') }} {{ letter_hour_mapping[role[:1]] }} {{ letter_day_mapping[role[:1]] }} * *"
|
||||||
# cron_timezone: Amsterdam
|
cron_timezone: Amsterdam
|
||||||
|
|
||||||
# - name: disable runnner
|
# - name: disable runnner
|
||||||
# uri:
|
# uri:
|
||||||
|
|
@ -104,18 +104,18 @@
|
||||||
# body:
|
# body:
|
||||||
# runner_id: "{{ gitlab_runner_id }}"
|
# runner_id: "{{ gitlab_runner_id }}"
|
||||||
|
|
||||||
- name: enable runnner
|
# - name: enable runnner
|
||||||
uri:
|
# uri:
|
||||||
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/runners"
|
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/runners"
|
||||||
method: POST
|
# method: POST
|
||||||
body_format: json
|
# body_format: json
|
||||||
status_code:
|
# status_code:
|
||||||
- 201
|
# - 201
|
||||||
- 400
|
# - 400
|
||||||
headers:
|
# headers:
|
||||||
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
|
||||||
body:
|
# body:
|
||||||
runner_id: "{{ gitlab_runner_id }}"
|
# runner_id: "{{ gitlab_runner_id }}"
|
||||||
|
|
||||||
- name: disable shared runnners
|
- name: disable shared runnners
|
||||||
uri:
|
uri:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
---
|
---
|
||||||
image: "robertdebock/github-action-molecule:4.0.8"
|
image: "robertdebock/github-action-molecule:5.0.0"
|
||||||
|
|
||||||
variables:
|
variables:
|
||||||
PY_COLORS: 1
|
PY_COLORS: 1
|
||||||
|
|
|
||||||
|
|
@ -46,7 +46,7 @@ jobs:
|
||||||
- name: parse apparmor for mysql
|
- name: parse apparmor for mysql
|
||||||
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
|
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
|
||||||
- name: molecule
|
- name: molecule
|
||||||
uses: robertdebock/molecule-action@4.0.8
|
uses: robertdebock/molecule-action@5.0.0
|
||||||
with:
|
with:
|
||||||
image: {% raw %}${{ matrix.config.image }}{% endraw %}
|
image: {% raw %}${{ matrix.config.image }}{% endraw %}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,22 +1,22 @@
|
||||||
{{ ansible_managed | comment }}
|
{{ ansible_managed | comment }}
|
||||||
[tox]
|
[tox]
|
||||||
minversion = 3.21.4
|
minversion = 4.2.4
|
||||||
{% if tox_ansible_versions is defined %}
|
{% if tox_ansible_versions is defined %}
|
||||||
envlist = py{310}-ansible-{% raw %}{{% endraw %}{% for version in tox_ansible_versions %}{{ version }}{% if not loop.last %},{% endif %}{% endfor %}{% raw %}}{% endraw %}
|
envlist = py{310}-ansible{% raw %}{{% endraw %}{% for version in tox_ansible_versions %}{{ version }}{% if not loop.last %},{% endif %}{% endfor %}{% raw %}}{% endraw %}
|
||||||
{% else %}
|
{% else %}
|
||||||
envlist = py{310}-ansible-{5,6,7}
|
envlist = py{310}-ansible{5,6,7}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
skipsdist = true
|
skipsdist = true
|
||||||
|
|
||||||
[testenv]
|
[testenv]
|
||||||
deps =
|
deps =
|
||||||
5: ansible == 5.*
|
ansible5: ansible == 5.*
|
||||||
6: ansible == 6.*
|
ansible6: ansible == 6.*
|
||||||
7: ansible == 7.*
|
ansible7: ansible == 7.*
|
||||||
molecule[docker]
|
molecule[docker]
|
||||||
docker == 5.*
|
docker == 6.*
|
||||||
ansible-lint == 5.*
|
ansible-lint == 6.*
|
||||||
commands = molecule test
|
commands = molecule test
|
||||||
setenv =
|
setenv =
|
||||||
TOX_ENVNAME={envname}
|
TOX_ENVNAME={envname}
|
||||||
|
|
@ -24,4 +24,8 @@ setenv =
|
||||||
ANSIBLE_FORCE_COLOR=1
|
ANSIBLE_FORCE_COLOR=1
|
||||||
ANSIBLE_ROLES_PATH=../
|
ANSIBLE_ROLES_PATH=../
|
||||||
|
|
||||||
passenv = namespace image tag DOCKER_HOST
|
passenv =
|
||||||
|
namespace
|
||||||
|
image
|
||||||
|
tag
|
||||||
|
DOCKER_HOST
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue