Compare commits

...

27 Commits

Author SHA1 Message Date
Robert de Bock 5623672ed2 This action has a new version. 2024-09-12 15:06:33 +02:00
Robert de Bock 1d3d5007fd Pass all variables. 2024-08-30 14:35:56 +02:00
Robert de Bock d50237a72d More detail. 2024-08-21 09:23:03 +02:00
Robert de Bock ad61a0cad3 Different tox. 2024-08-21 09:22:47 +02:00
Robert de Bock 592357a35b Test multiple versions of python. 2024-07-20 08:10:28 +02:00
Robert de Bock 66bab3efda Tox reintroduced. 2024-07-20 08:10:10 +02:00
Robert de Bock d9fa8aa593 These should be quoted to match. 2024-07-12 21:47:27 +02:00
Robert de Bock e35a262476 Python2 is not supported anymore. 2024-07-02 09:17:15 +02:00
Robert de Bock 3b0f680563 Cleanup. 2024-07-01 15:18:24 +02:00
Robert de Bock 8789540434 Not RHEL, nor OpenSUSE. 2024-07-01 14:59:19 +02:00
Robert de Bock d939fe5214 Write is required. 2024-07-01 14:58:20 +02:00
Robert de Bock ebdb95d640 Simpler. 2024-07-01 14:57:47 +02:00
Robert de Bock f5f7444a59 This is a static file. 2024-07-01 14:54:28 +02:00
Robert de Bock 0caad4d975 Ansible 10. 2024-06-10 20:41:58 +02:00
Robert de Bock a3ff4a0ee5 Disable tox for now. 2024-05-23 08:35:33 +02:00
Robert de Bock 3ecb38499b Ubuntu noble added, drop bionic. 2024-04-25 13:24:18 +02:00
Robert de Bock 6e2afc05c6 Fedora 40. 2024-04-24 07:48:53 +02:00
Robert de Bock 15cddd986c More booleans. 2024-03-20 11:26:21 +01:00
Robert de Bock 1eacee4cc4 more yes no 2024-03-18 09:37:07 +01:00
Robert de Bock 2418dd9332 Change to true/false. 2024-03-18 09:05:47 +01:00
Robert de Bock fc3c738fb5 Finally: yes and no. 2024-03-15 10:34:02 +01:00
Robert de Bock a9b3e1d7f7 Two minor fixes. 2024-03-04 09:14:01 +01:00
Robert de Bock c0cf49ebc1 Newer version of the checkout action. 2024-01-30 11:27:18 +01:00
Robert de Bock 6b5112377b Galaxy ID is not used anymore. 2024-01-02 09:04:10 +01:00
Robert de Bock 988467b8c0 Brace fix. 2024-01-02 08:54:02 +01:00
Robert de Bock eef1e3a36c New badge for downloads. 2024-01-02 08:50:27 +01:00
Robert de Bock 2cef955aa5 Correct destination. 2023-12-19 07:59:02 +01:00
17 changed files with 160 additions and 135 deletions

View File

@ -186,7 +186,7 @@
same "printed page" as the copyright notice for easier same "printed page" as the copyright notice for easier
identification within third-party archives. identification within third-party archives.
Copyright 2023 Robert de Bock (robert@meinit.nl) Copyright 2024 Robert de Bock (robert@meinit.nl)
Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.

View File

@ -24,9 +24,9 @@ The intention is to focus on writing or maintaining the Ansible role, and use th
| templates/* | | | molecule/default/molecule.yml | | templates/* | | | molecule/default/molecule.yml |
+-------------------+ | +--- this tool ---+ | .github/workflows/requirements2png.yml | +-------------------+ | +--- this tool ---+ | .github/workflows/requirements2png.yml |
+--> | generate.yml | --> | SECURITY.md | +--> | generate.yml | --> | SECURITY.md |
+--- Galaxy ---+ | +-----------------+ | settings.yml | +-----------------+ | settings.yml |
| galaxy_id | --------+ | .github/workflows/todo.yml | | .github/workflows/todo.yml |
+--------------+ | .tox.ini | | .tox.ini |
+----------------------------------------+ +----------------------------------------+
``` ```

View File

@ -48,7 +48,6 @@ generate_github_action_molecule: yes
generate_github_action_galaxy: yes generate_github_action_galaxy: yes
generate_github_action_todo: yes generate_github_action_todo: yes
generate_gitlab_ci: yes generate_gitlab_ci: yes
generate_requirements_txt: yes
generate_requirements2png: yes generate_requirements2png: yes
generate_github_funding: yes generate_github_funding: yes
generate_github_issue_template: yes generate_github_issue_template: yes

View File

@ -0,0 +1,11 @@
---
name: Pull request
about: Describe the proposed change
---
**Describe the change**
A clear and concise description of what the pull request is.
**Testing**
In case a feature was added, how were tests performed?

3
files/requirements.txt Normal file
View File

@ -0,0 +1,3 @@
molecule
molecule-plugins[docker]
paramiko

View File

@ -9,7 +9,8 @@ rules:
max-spaces-inside: 1 max-spaces-inside: 1
level: error level: error
line-length: disable line-length: disable
truthy: disable truthy:
check-keys: false
ignore: | ignore: |
.tox/ .tox/

View File

@ -89,13 +89,6 @@
when: when:
- verify.stat.exists - verify.stat.exists
- name: Load galaxy_id
ansible.builtin.shell:
cmd: "set -o pipefail ; ansible-galaxy info {{ galaxy_namespace }}.{{ role_name }} | grep ' id: ' | awk '{print $NF}'" # noqa no-tabs
register: galaxy_id
changed_when: no
failed_when: no
- name: Create .github directories - name: Create .github directories
ansible.builtin.file: ansible.builtin.file:
path: "{{ role_path }}/{{ item }}" path: "{{ role_path }}/{{ item }}"
@ -126,6 +119,10 @@
dest: .yamllint dest: .yamllint
- source: pre-commit-config.yaml - source: pre-commit-config.yaml
dest: .pre-commit-config.yaml dest: .pre-commit-config.yaml
- source: pull_request_template.md
dest: .github/pull_request_template.md
- source: requirements.txt
dest: requirements.txt
loop_control: loop_control:
label: "{{ item.source }}" label: "{{ item.source }}"
@ -153,6 +150,11 @@
when: when:
- generate_tox - generate_tox
# - name: Remove tox.ini
# ansible.builtin.file:
# path: "{{ role_path }}/tox.ini"
# state: absent
- name: Render file .github/settings.yml - name: Render file .github/settings.yml
ansible.builtin.template: ansible.builtin.template:
src: "{{ playbook_dir }}/templates/settings.yml.j2" src: "{{ playbook_dir }}/templates/settings.yml.j2"
@ -196,7 +198,7 @@
- name: Render file .github/workflows/molecule.yml - name: Render file .github/workflows/molecule.yml
ansible.builtin.template: ansible.builtin.template:
src: "{{ playbook_dir }}/templates/molecule-action.yml.j2" src: "{{ playbook_dir }}/templates/molecule-action.yml.j2"
dest: "{{ role_path }}/.github/workflows/molecule.ymlmd" dest: "{{ role_path }}/.github/workflows/molecule.yml"
mode: "0644" mode: "0644"
when: when:
- generate_github_action_molecule - generate_github_action_molecule
@ -225,14 +227,6 @@
when: when:
- generate_gitlab_ci - generate_gitlab_ci
- name: Render file requirements.txt
ansible.builtin.template:
src: "{{ playbook_dir }}/templates/requirements.txt.j2"
dest: "{{ role_path }}/requirements.txt"
mode: "0644"
when:
- generate_requirements_txt
- name: Render file .github/workflows/requirements2png.yml - name: Render file .github/workflows/requirements2png.yml
ansible.builtin.template: ansible.builtin.template:
src: "{{ playbook_dir }}/templates/requirements2png.yml.j2" src: "{{ playbook_dir }}/templates/requirements2png.yml.j2"

View File

@ -4,7 +4,7 @@
|GitHub|GitLab|Downloads|Version| |GitHub|GitLab|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/{{ gitlab_namespace }}/ansible-role-{{ role_name }}/badges/master/pipeline.svg)](https://gitlab.com/{{ gitlab_namespace }}/ansible-role-{{ 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](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/{{ gitlab_namespace }}/ansible-role-{{ role_name }}/badges/master/pipeline.svg)](https://gitlab.com/{{ gitlab_namespace }}/ansible-role-{{ role_name }})|[![downloads](https://img.shields.io/ansible/role/d/{{ galaxy_namespace }}/{{ role_name }})](https://galaxy.ansible.com/{{ galaxy_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) ## [Example Playbook](#example-playbook)

View File

@ -17,8 +17,5 @@ exclude_paths:
- .github - .github
- requirements.yml - requirements.yml
skip_list:
- yaml[truthy]
enable_list: enable_list:
- name[prefix] - name[prefix]

View File

@ -1,13 +1,16 @@
--- ---
image: "{{ gitlab_container }}"
variables: variables:
PY_COLORS: 1 DEBIAN_FRONTEND: noninteractive
molecule: molecule:
image: $python
script: script:
- apt-get update -qq
- apt-get -y -qq install yamllint docker.io
- pip install --no-cache-dir tox
- if [ -f tox.ini ] ; then tox ; fi - if [ -f tox.ini ] ; then tox ; fi
- if [ ! -f tox.ini ] ; then molecule test ; fi - if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
rules: rules:
- if: $CI_COMMIT_REF_NAME == "master" - if: $CI_COMMIT_REF_NAME == "master"
parallel: parallel:
@ -17,6 +20,7 @@ molecule:
{% for tag in distribution_version_mapping[platform.name][version] %} {% for tag in distribution_version_mapping[platform.name][version] %}
- image: "{{ platform_image_mapping[platform.name] }}" - image: "{{ platform_image_mapping[platform.name] }}"
tag: "{{ tag }}" tag: "{{ tag }}"
python: {{ matrix_overrides[platform_image_mapping[platform.name] | lower ]["python"] | default(default_python_version) }}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}

View File

@ -16,45 +16,61 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
- name: ansible-lint - name: ansible-lint
uses: ansible-community/ansible-lint-action@main uses: ansible-community/ansible-lint-action@main
test: {% for python_version in default_python_version %}
{{ python_version | replace('.', '-') | replace(':', '-') }}:
needs: needs:
- lint - lint
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
container:
image: {{ python_version }}
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
config: config:
{% for platform in meta.galaxy_info.platforms %} {% for platform in meta.galaxy_info.platforms %}
{% for version in platform.versions %} {% for version in platform.versions %}
{% if matrix_overrides is defined %}
{% if matrix_overrides[platform_image_mapping[platform.name]] is defined %}
{% for override_python_version in matrix_overrides[platform_image_mapping[platform.name]]["python"] %}
{% if override_python_version == python_version %}
{% for tag in distribution_version_mapping[platform.name][version] %} {% for tag in distribution_version_mapping[platform.name][version] %}
- image: "{{ platform_image_mapping[platform.name] }}" - image: "{{ platform_image_mapping[platform.name] }}"
tag: "{{ tag }}" tag: "{{ tag }}"
{% endfor %} {% endfor %}
{% endif %}
{% endfor %}
{% else %}
{% for tag in distribution_version_mapping[platform.name][version] %}
- image: "{{ platform_image_mapping[platform.name] }}"
tag: "{{ tag }}"
{% endfor %}
{% endif %}
{% endif %}
{% endfor %} {% endfor %}
{% endfor %} {% endfor %}
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with:
path: {% raw %}"${{ github.repository }}"{% endraw %}
# - name: disable apparmor for mysql
# run: sudo ln -s /etc/apparmor.d/usr.sbin.mysqld /etc/apparmor.d/disable/
# - name: parse apparmor for mysql
# run: sudo apparmor_parser -R /etc/apparmor.d/usr.sbin.mysqld
- name: molecule - name: molecule
uses: {{ molecule_action }} run: |
with: apt-get update -qq
apt-get -y -qq install yamllint docker.io
pip install --no-cache-dir tox
if [ -f tox.ini ] ; then tox ; fi
if [ ! -f tox.ini ] ; then pip install -r requirements.yml ; pip install ansible-lint ansible-core ; molecule test ; fi
env:
image: {% raw %}${{ matrix.config.image }}{% endraw %} image: {% raw %}${{ matrix.config.image }}{% endraw %}
tag: {% raw %}${{ matrix.config.tag }}{% endraw %} tag: {% raw %}${{ matrix.config.tag }}{% endraw %}
{% if github_variables_mapping is defined %} {% if github_variables_mapping is defined %}
env:
{% for item in github_variables_mapping %} {% for item in github_variables_mapping %}
{{ item.variable }}: {% raw %}${{ {%endraw %}{{ item.name }} {% raw %}}}{% endraw %} {{ item.variable }}: {% raw %}${{ {%endraw %}{{ item.name }} {% raw %}}}{% endraw %}
{% endfor %} {% endfor %}
{% endif %} {% endif %}
{% endfor %}

View File

@ -16,9 +16,9 @@ platforms:
image: "${namespace:-{{ docker_namespace }}}/${image:-{{ docker_image }}}:${tag:-{{ docker_tag }}}" image: "${namespace:-{{ docker_namespace }}}/${image:-{{ docker_image }}}:${tag:-{{ docker_tag }}}"
command: /sbin/init command: /sbin/init
volumes: volumes:
- /sys/fs/cgroup:/sys/fs/cgroup:ro - /sys/fs/cgroup:/sys/fs/cgroup:rw
privileged: yes privileged: true
pre_build_image: yes pre_build_image: true
provisioner: provisioner:
name: ansible name: ansible
{% if github_variables_mapping is defined %} {% if github_variables_mapping is defined %}

View File

@ -1,5 +0,0 @@
ansible-compat == 4.*
molecule == 6.*
molecule-plugins[docker] == 23.*
ansible-lint == 6.*
paramiko == 3.*

View File

@ -13,7 +13,7 @@ jobs:
contents: write contents: write
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v3 uses: actions/checkout@v4
with: with:
path: {% raw %}${{ github.repository }}{% endraw %} path: {% raw %}${{ github.repository }}{% endraw %}

View File

@ -10,9 +10,9 @@ jobs:
build: build:
runs-on: "ubuntu-20.04" runs-on: "ubuntu-20.04"
steps: steps:
- uses: "actions/checkout@master" - uses: actions/checkout@v4
- name: "TODO to Issue" - name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v2.3" uses: "alstr/todo-to-issue-action@v4"
id: "todo" id: "todo"
with: with:
TOKEN: ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %} TOKEN: ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}

View File

@ -1,37 +1,48 @@
{{ ansible_managed | comment }}
[tox] [tox]
minversion = 4.2.4 envlist = ansible-2.{15,16,17}
{% if tox_ansible_versions is defined %}
envlist = py3-ansible{% raw %}{{% endraw %}{% for version in tox_ansible_versions %}{{ version }}{% if not loop.last %},{% endif %}{% endfor %}{% raw %}}{% endraw %}
{% else %}
# Ansible 7 is disabled, causing issues with Fedora:
# https://github.com/ansible/ansible/issues/81199#event-9773321055
# envlist = py3-ansible{7,8,9}
envlist = py3-ansible{8,9}
{% endif %}
skipsdist = true skipsdist = true
[testenv] [testenv]
deps =
-rrequirements.txt
ansible7: ansible == 7.*
ansible8: ansible == 8.*
ansible9: ansible == 9.*
commands = molecule test commands = molecule test
setenv = setenv =
TOX_ENVNAME={envname} TOX_ENVNAME={envname}
PY_COLORS=1 PY_COLORS=1
ANSIBLE_FORCE_COLOR=1 ANSIBLE_FORCE_COLOR=1
ANSIBLE_ROLES_PATH=../ ANSIBLE_ROLES_PATH=../
passenv = passenv = *
namespace
image # Test supported releases of ansible-core. See:
tag # https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix
DOCKER_HOST
{% if github_variables_mapping is defined %} [testenv:ansible-2.15]
{% for item in github_variables_mapping %} basepython = python3.9
{{ item.variable }} deps =
{% endfor %} -rrequirements.txt
{% endif %} ansible-core==2.15.*
ansible-lint==6.*
[testenv:ansible-2.16]
basepython = python3.10
deps =
-rrequirements.txt
ansible-core==2.16.*
ansible-lint==24.*
[testenv:ansible-2.17]
basepython = python3.10
deps =
-rrequirements.txt
ansible-core==2.17.*
ansible-lint==24.*
# Future work, not releases, just prepared. See:
# https://docs.ansible.com/ansible/devel//roadmap/ROADMAP_2_18.html
# Note: enable python3.13 in `vars/main.yml` as well.
# [testenv:ansible-2.18]
# basepython = python3.13
# deps =
# -rrequirements.txt
# ansible-core==2.18.*
# ansible-lint==24.*

View File

@ -1,6 +1,12 @@
--- ---
# Setting to generate files. # Setting to generate files.
# A list of python version to test.
default_python_version:
- "python:3.9"
- "python:3.10"
# - "python:3:13"
# A map that relates the `meta/main.yml` - `galaxy_info.platforms.name` to a name of a container. # A map that relates the `meta/main.yml` - `galaxy_info.platforms.name` to a name of a container.
platform_image_mapping: platform_image_mapping:
Alpine: alpine Alpine: alpine
@ -19,7 +25,7 @@ image_docker_hub_url_mapping:
archlinux: "https://hub.docker.com/r/{{ docker_namespace }}/archlinux" archlinux: "https://hub.docker.com/r/{{ docker_namespace }}/archlinux"
debian: "https://hub.docker.com/r/{{ docker_namespace }}/debian" debian: "https://hub.docker.com/r/{{ docker_namespace }}/debian"
el: "https://hub.docker.com/r/{{ docker_namespace }}/enterpriselinux" el: "https://hub.docker.com/r/{{ docker_namespace }}/enterpriselinux"
fedora: "https://hub.docker.com/r/{{ docker_namespace }}/fedora/" fedora: "https://hub.docker.com/r/{{ docker_namespace }}/fedora"
opensuse: "https://hub.docker.com/r/{{ docker_namespace }}/opensuse" opensuse: "https://hub.docker.com/r/{{ docker_namespace }}/opensuse"
ubuntu: "https://hub.docker.com/r/{{ docker_namespace }}/ubuntu" ubuntu: "https://hub.docker.com/r/{{ docker_namespace }}/ubuntu"
@ -31,10 +37,7 @@ distribution_version_mapping:
- latest - latest
Amazon: Amazon:
all: all:
- 1
- latest - latest
"2018.03":
- 1
Candidate: Candidate:
- latest - latest
Archlinux: Archlinux:
@ -42,52 +45,43 @@ distribution_version_mapping:
- latest - latest
Debian: Debian:
all: all:
- latest - latest # 12
- bullseye - bullseye # 11
bullseye: bullseye:
- bullseye - bullseye
buster:
- buster
bookworm: bookworm:
- latest - latest
buster:
- buster
EL: EL:
all: all:
- 7
- 8
- latest - latest
"7":
- 7
"8":
- 8
"9": "9":
- latest - latest
Fedora: Fedora:
all: all:
- 38 - 39
- latest - latest
- rawhide - rawhide
"37":
- 37
"38": "38":
- 38 - 38
"39": "39":
- latest - 39
"40": "40":
- rawhide
opensuse:
all:
- latest - latest
"41":
- rawhide
Ubuntu: Ubuntu:
all: all:
- latest # 24
- jammy # 22
- focal # 20
noble:
- latest - latest
- focal
- bionic
jammy: jammy:
- latest - jammy
focal: focal:
- focal - focal
bionic:
- bionic
# To schedule CI on different days of the month, this is a map that relates a letter to a day of the month. # To schedule CI on different days of the month, this is a map that relates a letter to a day of the month.
letter_day_mapping: letter_day_mapping:
@ -117,16 +111,16 @@ letter_day_mapping:
x: 24 x: 24
y: 25 y: 25
z: 26 z: 26
0: 27 "0": 27
1: 27 "1": 27
2: 27 "2": 27
3: 27 "3": 27
4: 27 "4": 27
5: 27 "5": 27
6: 27 "6": 27
7: 27 "7": 27
8: 27 "8": 27
9: 27 "9": 27
# To schedule CI on different hours of the day, this is a map that relates a letter to an hour of the day. # To schedule CI on different hours of the day, this is a map that relates a letter to an hour of the day.
letter_hour_mapping: letter_hour_mapping:
@ -156,16 +150,16 @@ letter_hour_mapping:
x: 22 x: 22
y: 22 y: 22
z: 22 z: 22
0: 23 "0": 23
1: 23 "1": 23
2: 23 "2": 23
3: 23 "3": 23
4: 23 "4": 23
5: 23 "5": 23
6: 23 "6": 23
7: 23 "7": 23
8: 23 "8": 23
9: 23 "9": 23
# To schedule CI on different days of the month, this is a map that relates a letter to a minute of the hour. # To schedule CI on different days of the month, this is a map that relates a letter to a minute of the hour.
letter_minute_mapping: letter_minute_mapping:
@ -195,13 +189,13 @@ letter_minute_mapping:
x: 47 x: 47
y: 49 y: 49
z: 51 z: 51
0: 53 "0": 53
1: 55 "1": 55
2: 57 "2": 57
3: 59 "3": 59
4: 59 "4": 59
5: 59 "5": 59
6: 59 "6": 59
7: 59 "7": 59
8: 59 "8": 59
9: 59 "9": 59