This commit is contained in:
Robert de Bock 2023-01-03 14:50:40 +01:00
parent ec9720777b
commit 4f25fb8469
10 changed files with 166 additions and 36 deletions

View File

@ -81,7 +81,6 @@ This optional file describes how Travis, Tox and Molecule should behave.
```yaml
---
tox_ansible_versions:
- 4
- 5
- 7
enterprise_linx: centos
```

View File

@ -19,7 +19,6 @@ repos:
- id: ansible_role_find_unused_variable
- id: ansible_role_find_empty_files
- id: ansible_role_find_empty_directories
- id: ansible_role_fix_readability
- id: ansible_role_find_undefined_handlers
- id: ansible_role_find_unquoted_values
- id: ansible_role_find_horizontal_when

96
github.yml Executable file
View File

@ -0,0 +1,96 @@
#!/usr/bin/env ansible-playbook
---
- name: github
hosts: localhost
become: no
gather_facts: no
vars_files:
# - defaults/main.yml
- vars/main.yml
- vars/vault.yml
pre_tasks:
- name: see if all variables are set
assert:
that:
- github_namespace is defined
- repo is defined
- github_token is defined
quiet: yes
tasks:
- name: list webhooks
uri:
url: "https://api.github.com/repos/{{ github_namespace }}/{{ repo }}/hooks"
headers:
Accept: "application/vnd.github+json"
Authorization: "Bearer {{ github_token }}"
register: github_webhooks
- name: show delivery url for gitlab webhook
set_fact:
deliveries_url: "{{ item.deliveries_url }}"
loop: "{{ github_webhooks.json }}"
loop_control:
label: "{{ item.id }}"
when:
- '"gitlab.com" in item.config.url'
- name: list delivery
uri:
url: "{{ deliveries_url }}"
headers:
Accept: "application/vnd.github+json"
Authorization: "Bearer {{ github_token }}"
register: deliveries
- name: add repo to github-okay.txt
lineinfile:
line: "{{ repo }}"
path: github-okay.txt
create: yes
loop: "{{ deliveries.json }}"
loop_control:
label: "{{ repo }} - {{ item.id }} - {{ item.status_code }}"
when:
- item.event == "push"
- item.status_code == 200
- name: remove repo from github-okay.txt
lineinfile:
line: "{{ repo }}"
path: github-okay.txt
state: absent
create: yes
loop: "{{ deliveries.json }}"
loop_control:
label: "{{ repo }} - {{ item.id }} - {{ item.status_code }}"
when:
- item.event == "push"
- item.status_code != 200
- name: add repo to github-fail.txt
lineinfile:
line: "{{ repo }}"
path: github-fail.txt
create: yes
loop: "{{ deliveries.json }}"
loop_control:
label: "{{ repo }} - {{ item.id }} - {{ item.status_code }}"
when:
- item.event == "push"
- item.status_code != 200
- name: remove repo from github-fail.txt
lineinfile:
line: "{{ repo }}"
path: github-fail.txt
state: absent
create: yes
loop: "{{ deliveries.json }}"
loop_control:
label: "{{ repo }} - {{ item.id }} - {{ item.status_code }}"
when:
- item.event == "push"
- item.status_code == 200

35
gitlab-delete-project.yml Executable file
View File

@ -0,0 +1,35 @@
#!/usr/bin/env ansible-playbook
---
- name: delete a gitlab repository
hosts: localhost
become: no
gather_facts: no
vars:
namespace: robertdebock
vars_files:
- vars/main.yml
- vars/vault.yml
tasks:
- name: see if all variables are set
assert:
that:
- namespace is defined
- role is defined
quiet: yes
- name: urlencode path
set_fact:
encoded_path: "{{ namespace + '%2F' + role }}"
- name: delete project
uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}"
method: DELETE
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
status_code:
- 202
- 404

View File

@ -76,20 +76,20 @@
loop_control:
label: "{{ item.id }}"
- name: create a new pipeline schedule
uri:
url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
method: POST
body_format: json
status_code:
- 201
headers:
PRIVATE-TOKEN: "{{ gitlab_private_token }}"
body:
description: "Monthly test"
ref: master
cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
cron_timezone: Amsterdam
# - name: create a new pipeline schedule
# uri:
# url: "https://gitlab.com/api/v4/projects/{{ encoded_path }}/pipeline_schedules"
# method: POST
# body_format: json
# status_code:
# - 201
# headers:
# PRIVATE-TOKEN: "{{ gitlab_private_token }}"
# body:
# description: "Monthly test"
# ref: master
# cron: "{{ letter_minute_mapping[role[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
# cron_timezone: Amsterdam
# - name: disable runnner
# uri:

View File

@ -55,6 +55,7 @@ Most roles require some kind of preparation, this is done in `molecule/default/p
{% for dependency in meta.dependencies %}
- {{ dependency }}
{% endfor %}
{% endif %}
## [Context](#context)

View File

@ -1,9 +1,6 @@
---
image: "robertdebock/github-action-molecule:4.0.8"
# services:
# - docker:dind
variables:
PY_COLORS: 1
@ -13,7 +10,6 @@ molecule:
- if [ ! -f tox.ini ] ; then molecule test ; fi
rules:
- if: $CI_COMMIT_REF_NAME == "master"
retry: 1
parallel:
matrix:
{% for platform in meta.galaxy_info.platforms %}

View File

@ -4,16 +4,16 @@ minversion = 3.21.4
{% 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 %}
{% else %}
envlist = py{310}-ansible-{4,5,6}
envlist = py{310}-ansible-{5,6,7}
{% endif %}
skipsdist = true
[testenv]
deps =
4: ansible == 4.*
5: ansible == 5.*
6: ansible == 6.*
7: ansible == 7.*
molecule[docker]
docker == 5.*
ansible-lint == 5.*

View File

@ -68,14 +68,14 @@ distribution_version_mapping:
- latest
Fedora:
all:
- 35
- 36
- latest
- rawhide
"35":
- 35
"36":
- latest
- 36
"37":
- latest
"38":
- rawhide
opensuse:
all:

View File

@ -1,10 +1,14 @@
$ANSIBLE_VAULT;1.1;AES256
63333963376266386263383966303436353065346139656263333133346433333064633032663938
3236306464376332383938356264333933633938626435330a373939643261356639373539656333
31633035633131386363613233653436646338333537613665383337613461643161636332333332
6135333135636334620a353963383037653830633136333930663439353665323064303234373666
65313339393334333831316335353831343264373833373131613162646334323362636466326165
34373062373331666234353338376339663939313463323437323166346432383130323939376437
34623265396265326538663731306333323435646430373935633738653034323463373261313832
35613036636566303036363131343762643665616638353837363439613430386533356663346538
36306661346266653739623937653635323037633232623562396665646238373238
35626138373665613930386237633532396164326166376163316366366432393338303535303163
6435353933333036376462376232366338616335356631310a633732336234386438303761666332
33643039346337393637346535343966616237376532646561363765663639356138353766303239
6333313664656339360a393362326563643366376531366563373363396530666138663431346261
30333566626130363638333162623537316539656264393238656136336431366133636330393635
61366365613938343063353631633466623466623634343062656233303663663166313836346432
35386133356664393235373364343534306635326365346465623462376162396539646538613664
33666562633565643732613637313730306465663730363263346665663064326363396164616165
61323535346661633364643663623730623662373765663861323236613164623266663361653734
62666439353333666333323432613439393336643536663237393734313234376532333532353339
65616634616230613632326162313962373665396265343838333363623437353238633231356262
33353131616565353065346131636133313833633539323832376262386438303333363763613039
3235