This commit is contained in:
Robert de Bock 2021-02-18 13:09:28 +01:00
parent b8a0bdfbcd
commit 7cb81c4f96
14 changed files with 82 additions and 59 deletions

4
files/collections.yml Normal file
View File

@ -0,0 +1,4 @@
---
collections:
- name: community.docker
- name: community.general

View File

@ -8,13 +8,13 @@ repos:
- id: check-added-large-files
- repo: https://github.com/adrienverge/yamllint
rev: v1.25.0
rev: v1.26.0
hooks:
- id: yamllint
args: [-c=.yamllint]
- repo: https://github.com/ansible/ansible-lint
rev: v4.3.7
rev: v5.0.1
hooks:
- id: ansible-lint
pass_filenames: false

View File

@ -13,3 +13,4 @@ rules:
ignore: |
.tox/
.cache/

View File

@ -148,6 +148,8 @@
dest: .github/FUNDING.yml
- source: pre-commit-config.yaml
dest: .pre-commit-config.yaml
- source: collections.yml
dest: molecule/default/collections.yml
loop_control:
label: "{{ item.source }}"
@ -180,6 +182,8 @@
- source: gitlab-ci.yml
dest: .gitlab-ci.yml
- source: requirements.txt
- source: requirements2png.yml
dest: .github/workflows/requirements2png.yml
loop_control:
label: "{{ item.source }}"

View File

@ -68,4 +68,4 @@
description: "Monthly test"
ref: master
cron: '{{ letter_minute_mapping[role[0]] }} {{ letter_hour_mapping[role[0]] }} {{ letter_day_mapping[role[0]] }} * *'
cron_timezone: UTC
cron_timezone: Amsterdam

View File

@ -9,8 +9,8 @@ directory="/home/robertdb/Documents/github.com/robertdebock"
pattern="ansible-role-"
# Print the header of the table.
echo "|Role name|Travis|GitHub Action|GitLab CI|Version|"
echo "|---------|------|-------------|---------|-------|"
echo "|Role name|GitHub Action|GitLab CI|Version|"
echo "|---------|-------------|---------|-------|"
# Loop over the found roles.
cd ${directory} ; ls -d "${pattern}"* | while read rolename ; do
@ -20,12 +20,11 @@ cd ${directory} ; ls -d "${pattern}"* | while read rolename ; do
# Save the markdown per column in a variable, better readable loop.
galaxy="[${shortrolename}](https://galaxy.ansible.com/robertdebock/${shortrolename})"
travis="[![travis](https://api.travis-ci.com/robertdebock/${rolename}.svg?branch=master)](https://travis-ci.com/robertdebock/${rolename})"
github="[![github](https://github.com/robertdebock/${rolename}/workflows/Ansible%20Molecule/badge.svg)](https://github.com/robertdebock/${rolename}/actions)"
gitlab="[![gitlab](https://gitlab.com/robertdebock/${rolename}/badges/master/pipeline.svg)](https://gitlab.com/robertdebock/${rolename})"
version="[![version](https://img.shields.io/github/commits-since/robertdebock/${rolename}/latest.svg)](https://github.com/robertdebock/${rolename}/releases)"
# Print the line of one role.
echo "|${galaxy}|${travis}|${github}|${gitlab}|${version}|"
echo "|${galaxy}|${github}|${gitlab}|${version}|"
done

View File

@ -2,9 +2,9 @@
{{ meta.galaxy_info.description }}
|Travis|GitHub|GitLab|Quality|Downloads|Version|
|------|------|------|-------|---------|-------|
|[![travis](https://travis-ci.com/{{ travis_namespace }}/ansible-role-{{ role_name }}.svg?branch=master)](https://travis-ci.com/{{ travis_namespace }}/ansible-role-{{ role_name }})|[![github](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/workflows/Ansible%20Molecule/badge.svg)](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/actions)|[![gitlab](https://gitlab.com/{{ github_namespace }}/ansible-role-{{ role_name }}/badges/master/pipeline.svg)](https://gitlab.com/{{ github_namespace }}/ansible-role-{{ role_name }})|[![quality](https://img.shields.io/ansible/quality/{{ galaxy_id.stdout | default('unset') }})](https://galaxy.ansible.com/{{ github_namespace }}/{{ role_name }})|[![downloads](https://img.shields.io/ansible/role/d/{{ galaxy_id.stdout |default('unset') }})](https://galaxy.ansible.com/{{ github_namespace }}/{{ role_name }})|[![Version](https://img.shields.io/github/release/{{ github_namespace }}/ansible-role-{{ role_name }}.svg)](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/releases/)|
|GitHub|GitLab|Quality|Downloads|Version|
|------|------|-------|---------|-------|
|[![github](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/workflows/Ansible%20Molecule/badge.svg)](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/actions)|[![gitlab](https://gitlab.com/{{ github_namespace }}/ansible-role-{{ role_name }}/badges/master/pipeline.svg)](https://gitlab.com/{{ github_namespace }}/ansible-role-{{ role_name }})|[![quality](https://img.shields.io/ansible/quality/{{ galaxy_id.stdout | default('unset') }})](https://galaxy.ansible.com/{{ github_namespace }}/{{ role_name }})|[![downloads](https://img.shields.io/ansible/role/d/{{ galaxy_id.stdout |default('unset') }})](https://galaxy.ansible.com/{{ github_namespace }}/{{ role_name }})|[![Version](https://img.shields.io/github/release/{{ github_namespace }}/ansible-role-{{ role_name }}.svg)](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/releases/)|
## [Example Playbook](#example-playbook)
@ -37,10 +37,10 @@ These variables are set in `defaults/main.yml`:
The following roles are used to prepare a system. You may choose to prepare your system in another way, I have tested these roles as well.
| Requirement | Travis | GitHub |
| Requirement | GitHub | GitLab |
|-------------|--------|--------|
{% for requirement in requirements.roles %}
| [{{ requirement.name }}](https://galaxy.ansible.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.') }}) | [![Build Status Travis](https://travis-ci.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}.svg?branch=master)](https://travis-ci.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}) | [![Build Status GitHub](https://github.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}/workflows/Ansible%20Molecule/badge.svg)](https://github.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}/actions) |
| [{{ requirement.name }}](https://galaxy.ansible.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.') }}) | [![Build Status GitHub](https://github.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}/workflows/Ansible%20Molecule/badge.svg)](https://github.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}/actions) | [![Build Status GitLab ](https://gitlab.com/{{ github_namespace }}/ansible-role-{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }}/badges/master/pipeline.svg)](https://gitlab.com/{{ github_namespace }}/{{ requirement.name | regex_replace(github_namespace + '\.', 'ansible-role-') }})
{% endfor %}
{% endif %}
@ -58,7 +58,7 @@ Most roles require some kind of preparation, this is done in `molecule/default/p
This role is a part of many compatible roles. Have a look at [the documentation of these roles](https://robertdebock.nl/) for further information.
Here is an overview of related roles:
![dependencies](https://raw.githubusercontent.com/{{ github_namespace }}/drawings/artifacts/{{ role_name }}.png "Dependency")
![dependencies](https://raw.githubusercontent.com/{{ github_namespace }}/ansible-role-{{ role_name }}/png/requirements.png "Dependencies")
## [Compatibility](#compatibility)
@ -96,40 +96,8 @@ This role [refers to a version]({{ reference }}) released by {{ project_name }}.
This version reference means a role may get outdated. Monthly tests occur to see if [bit-rot](https://en.wikipedia.org/wiki/Software_rot) occured. If you however find a problem, please create an issue, I'll get on it as soon as possible.{% endif %}
## [Testing](#testing)
[Unit tests](https://travis-ci.com/{{ travis_namespace }}/ansible-role-{{ role_name }}) are done on every commit, pull request, release and periodically.
If you find issues, please register them in [GitHub](https://github.com/{{ github_namespace }}/ansible-role-{{ role_name }}/issues)
Testing is done using [Tox](https://tox.readthedocs.io/en/latest/) and [Molecule](https://github.com/ansible/molecule):
[Tox](https://tox.readthedocs.io/en/latest/) tests multiple ansible versions.
[Molecule](https://github.com/ansible/molecule) tests multiple distributions.
To test using the defaults (any installed ansible version, namespace: `{{ docker_namespace }}`, image: `{{ docker_image }}`, tag: `{{ docker_tag }}`):
```
molecule test
# Or select a specific image:
image=ubuntu molecule test
# Or select a specific image and a specific tag:
image="debian" tag="stable" tox
```
Or you can test multiple versions of Ansible, and select images:
Tox allows multiple versions of Ansible to be tested. To run the default (namespace: `{{ docker_namespace }}`, image: `{{ docker_image }}`, tag: `{{ docker_tag }}`) tests:
```
tox
# To run CentOS (namespace: `{{ docker_namespace }}`, tag: `{{ docker_tag }}`)
image="centos" tox
# Or customize more:
image="debian" tag="stable" tox
```
## [License](#license)
{{ meta.galaxy_info.license }}

View File

@ -10,8 +10,12 @@ exclude_paths:
{% if preferencesymlstat.stat.exists %}
- ./meta/preferences.yml
{% endif %}
- ./molecule/default/prepare.yml
- ./molecule/default/converge.yml
{% if verify.stat.exists %}
- ./molecule/default/verify.yml
{% endif %}
{% endif %}
- ./molecule/default/collections.yml
- ./.tox
- ./.cache

View File

@ -12,7 +12,7 @@ molecule:
script:
- image=${image} tag=${tag} molecule test
rules:
- if: $CI_COMMIT_TAG == null
- if: $CI_COMMIT_REF_NAME == "master"
retry: 2
parallel:
matrix:

View File

@ -21,7 +21,7 @@ jobs:
path: {% raw %}"${{ github.repository }}"{% endraw %}
- name: molecule
uses: robertdebock/molecule-action@2.6.8
uses: robertdebock/molecule-action@2.6.16
with:
command: lint
test:
@ -51,7 +51,7 @@ jobs:
- name: parse apparmor for mysql
run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: molecule
uses: robertdebock/molecule-action@2.6.8
uses: robertdebock/molecule-action@2.6.16
with:
image: {% raw %}${{ matrix.config.image }}{% endraw %}

View File

@ -4,6 +4,9 @@ dependency:
name: galaxy
options:
role-file: requirements.yml
{% if requirements.collections is defined %}
requirements-file: requirements.yml
{% endif %}
lint: |
set -e
yamllint .

View File

@ -0,0 +1,36 @@
---
{{ ansible_managed | comment }}
on:
- push
name: Ansible Graphviz
jobs:
build:
runs-on: ubuntu-20.04
steps:
- name: checkout
uses: actions/checkout@v2
with:
path: {% raw %}${{ github.repository }}{% endraw %}
- name: create png
uses: robertdebock/graphviz-action@1.0.7
- name: Commit files
run: |
cd {% raw %}${{ github.repository }}{% endraw %}
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git add requirements.dot requirements.png
git commit -m "Add generated files"
- name: save to png branch
uses: ad-m/github-push-action@master
with:
github_token: {% raw %}${{ secrets.GITHUB_TOKEN }}{% endraw %}
directory: {% raw %}${{ github.repository }}{% endraw %}
force: true
branch: png

View File

@ -1,26 +1,28 @@
{{ ansible_managed | comment }}
[tox]
minversion = 3.20
minversion = 3.21.4
{% if tox_versions is defined %}
envlist = py{39}-ansible-{% raw %}{{% endraw %}{% for version in tox_versions %}{{ version }}{% if not loop.last %},{% endif %}{% endfor %}{% raw %}}{% endraw %}
{% else %}
envlist = py{39}-ansible-{previous,current}
# 2.11 has been disabled: couldn't resolve module/action 'docker_container'.
envlist = py{39}-ansible-{2.9,2.10}
{% endif %}
skipsdist = true
[testenv]
deps =
previous: ansible>=2.9, <2.10
current: ansible
next: git+https://github.com/ansible/ansible.git@devel
molecule[docker]>=3, <4
docker>=4.2, <4.3
ansible-lint
2.9: ansible == 2.9.*
2.10: ansible == 2.10.*
2.11: git+https://github.com/ansible/ansible.git@devel
molecule[docker]
docker == 4.*
ansible-lint == 5.*
commands = molecule test
setenv =
TOX_ENVNAME={envname}
PY_COLORS=1
ANSIBLE_FORCE_COLOR=1
ANSIBLE_ROLES_PATH=../
passenv = namespace image tag

View File

@ -67,13 +67,15 @@ distribution_version_mapping:
all:
- 32
- latest
- rawhide
# RawHide has package-GPG issues.
# - rawhide
32:
- 32
33:
- latest
34:
- rawhide
# RawHide has package-GPG issues.
# 34:
# - rawhide
OpenSUSE:
all:
- latest