Compare commits

..

No commits in common. "master" and "3.3.0" have entirely different histories.

17 changed files with 135 additions and 160 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 2024 Robert de Bock (robert@meinit.nl) Copyright 2023 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 |
+-----------------+ | settings.yml | +--- Galaxy ---+ | +-----------------+ | settings.yml |
| .github/workflows/todo.yml | | galaxy_id | --------+ | .github/workflows/todo.yml |
| .tox.ini | +--------------+ | .tox.ini |
+----------------------------------------+ +----------------------------------------+
``` ```

View File

@ -48,6 +48,7 @@ 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

@ -1,11 +0,0 @@
---
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?

View File

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

View File

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

View File

@ -89,6 +89,13 @@
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 }}"
@ -119,10 +126,6 @@
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 }}"
@ -150,11 +153,6 @@
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"
@ -198,7 +196,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.yml" dest: "{{ role_path }}/.github/workflows/molecule.ymlmd"
mode: "0644" mode: "0644"
when: when:
- generate_github_action_molecule - generate_github_action_molecule
@ -227,6 +225,14 @@
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_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/)| |[![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/)|
## [Example Playbook](#example-playbook) ## [Example Playbook](#example-playbook)

View File

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

View File

@ -1,16 +1,13 @@
--- ---
image: "{{ gitlab_container }}"
variables: variables:
DEBIAN_FRONTEND: noninteractive PY_COLORS: 1
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 pip install -r requirements.yml ; pip install ansible-lint ansible-core ; 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"
parallel: parallel:
@ -20,7 +17,6 @@ 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,61 +16,45 @@ jobs:
runs-on: ubuntu-20.04 runs-on: ubuntu-20.04
steps: steps:
- name: checkout - name: checkout
uses: actions/checkout@v4 uses: actions/checkout@v3
- name: ansible-lint - name: ansible-lint
uses: ansible-community/ansible-lint-action@main uses: ansible-community/ansible-lint-action@main
{% for python_version in default_python_version %} test:
{{ 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@v4 uses: actions/checkout@v3
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
run: | uses: {{ molecule_action }}
apt-get update -qq with:
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:rw - /sys/fs/cgroup:/sys/fs/cgroup:ro
privileged: true privileged: yes
pre_build_image: true pre_build_image: yes
provisioner: provisioner:
name: ansible name: ansible
{% if github_variables_mapping is defined %} {% if github_variables_mapping is defined %}

View File

@ -0,0 +1,5 @@
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@v4 uses: actions/checkout@v3
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@v4 - uses: "actions/checkout@master"
- name: "TODO to Issue" - name: "TODO to Issue"
uses: "alstr/todo-to-issue-action@v4" uses: "alstr/todo-to-issue-action@v2.3"
id: "todo" id: "todo"
with: with:
TOKEN: ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %} TOKEN: ${% raw %}{{ secrets.GITHUB_TOKEN }}{% endraw %}

View File

@ -1,48 +1,37 @@
{{ ansible_managed | comment }}
[tox] [tox]
envlist = ansible-2.{15,16,17} minversion = 4.2.4
{% 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
# Test supported releases of ansible-core. See: image
# https://docs.ansible.com/ansible/latest/reference_appendices/release_and_maintenance.html#ansible-core-support-matrix tag
DOCKER_HOST
[testenv:ansible-2.15] {% if github_variables_mapping is defined %}
basepython = python3.9 {% for item in github_variables_mapping %}
deps = {{ item.variable }}
-rrequirements.txt {% endfor %}
ansible-core==2.15.* {% endif %}
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,12 +1,6 @@
--- ---
# 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
@ -25,7 +19,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"
@ -37,7 +31,10 @@ distribution_version_mapping:
- latest - latest
Amazon: Amazon:
all: all:
- 1
- latest - latest
"2018.03":
- 1
Candidate: Candidate:
- latest - latest
Archlinux: Archlinux:
@ -45,43 +42,52 @@ distribution_version_mapping:
- latest - latest
Debian: Debian:
all: all:
- latest # 12 - latest
- bullseye # 11 - bullseye
bullseye: bullseye:
- bullseye - bullseye
bookworm:
- latest
buster: buster:
- buster - buster
bookworm:
- latest
EL: EL:
all: all:
- 7
- 8
- latest - latest
"7":
- 7
"8":
- 8
"9": "9":
- latest - latest
Fedora: Fedora:
all: all:
- 39 - 38
- latest - latest
- rawhide - rawhide
"37":
- 37
"38": "38":
- 38 - 38
"39": "39":
- 39
"40":
- latest - latest
"41": "40":
- rawhide - rawhide
opensuse:
all:
- latest
Ubuntu: Ubuntu:
all: all:
- latest # 24
- jammy # 22
- focal # 20
noble:
- latest - latest
- focal
- bionic
jammy: jammy:
- jammy - latest
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:
@ -111,16 +117,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:
@ -150,16 +156,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:
@ -189,13 +195,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