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 ```yaml
--- ---
tox_ansible_versions: tox_ansible_versions:
- 4 - 7
- 5
enterprise_linx: centos enterprise_linx: centos
``` ```

View File

@ -19,7 +19,6 @@ repos:
- id: ansible_role_find_unused_variable - id: ansible_role_find_unused_variable
- id: ansible_role_find_empty_files - id: ansible_role_find_empty_files
- id: ansible_role_find_empty_directories - id: ansible_role_find_empty_directories
- id: ansible_role_fix_readability
- id: ansible_role_find_undefined_handlers - id: ansible_role_find_undefined_handlers
- id: ansible_role_find_unquoted_values - id: ansible_role_find_unquoted_values
- id: ansible_role_find_horizontal_when - 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: 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[15]] | default('13') }} {{ letter_hour_mapping[role[13]] }} {{ letter_day_mapping[role[13]] }} * *"
cron_timezone: Amsterdam # cron_timezone: Amsterdam
# - name: disable runnner # - name: disable runnner
# uri: # 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 %} {% for dependency in meta.dependencies %}
- {{ dependency }} - {{ dependency }}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
## [Context](#context) ## [Context](#context)

View File

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

View File

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

View File

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

View File

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