Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c617bee02a | ||
|
|
f7da80b326 | ||
|
|
1029d8ecce | ||
|
|
535926b36e | ||
|
|
595f517b49 | ||
|
|
d732ac0a71 | ||
|
|
f62097a748 |
No files matched your search
@@ -6,6 +6,7 @@ profile: production
|
|||||||
exclude_paths:
|
exclude_paths:
|
||||||
- .gitea
|
- .gitea
|
||||||
- .venv
|
- .venv
|
||||||
|
- .venv-dev
|
||||||
- apm_modules
|
- apm_modules
|
||||||
- apm.lock.yaml
|
- apm.lock.yaml
|
||||||
- changelogs
|
- changelogs
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ jobs:
|
|||||||
timeout-minutes: 30
|
timeout-minutes: 30
|
||||||
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
# The ci image (images/ci, built by image.yml): tag for the release, digest enforced.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
steps:
|
steps:
|
||||||
@@ -94,13 +94,13 @@ jobs:
|
|||||||
# ansible-galaxy dereferences symlinks when it builds, so a symlink in the source tree
|
# ansible-galaxy dereferences symlinks when it builds, so a symlink in the source tree
|
||||||
# reaches the archive as a regular file with the target's content, where
|
# reaches the archive as a regular file with the target's content, where
|
||||||
# scripts/check_tarball.py cannot see it. Refuse them in the tree instead: this step
|
# scripts/check_tarball.py cannot see it. Refuse them in the tree instead: this step
|
||||||
# is the only guard against a file symlink. The two -prune paths below (./.venv,
|
# is the only guard against a file symlink. The -prune paths below (./.git, ./.venv,
|
||||||
# ./.git) are skipped only because the build skips them too (galaxy.yml build_ignore,
|
# ./.venv-dev) are skipped only because the build skips them too (galaxy.yml build_ignore,
|
||||||
# and ansible-galaxy's own .git exclusion): the two lists must stay in step, and
|
# and ansible-galaxy's own .git exclusion): the two lists must stay in step, and
|
||||||
# tests/scripts/test_check_tarball.py fails when a pruned directory is not ignored.
|
# tests/scripts/test_check_tarball.py fails when a pruned directory is not ignored.
|
||||||
- name: Refuse symlinks in the source tree
|
- name: Refuse symlinks in the source tree
|
||||||
run: |
|
run: |
|
||||||
links="$(find . -path ./.git -prune -o -path ./.venv -prune -o -type l -print)"
|
links="$(find . -path ./.git -prune -o -path ./.venv -prune -o -path ./.venv-dev -prune -o -type l -print)"
|
||||||
if [ -n "$links" ]; then
|
if [ -n "$links" ]; then
|
||||||
echo "::error::symlinks in the source tree would be dereferenced into the Collection archive:"
|
echo "::error::symlinks in the source tree would be dereferenced into the Collection archive:"
|
||||||
echo "$links"
|
echo "$links"
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ jobs:
|
|||||||
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
# The ci image (images/ci, built by image.yml), at the pin of lint.yml: tag for the
|
||||||
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
# release, digest enforced. Only its /opt/venv Python (with PyYAML) is used here.
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
steps:
|
steps:
|
||||||
# The container has no Node, so JavaScript actions such as actions/checkout
|
# The container has no Node, so JavaScript actions such as actions/checkout
|
||||||
# cannot run; clone with git and the job token.
|
# cannot run; clone with git and the job token.
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ jobs:
|
|||||||
# The tag says which release, the digest is what is enforced (bump both together
|
# The tag says which release, the digest is what is enforced (bump both together
|
||||||
# when image.yml publishes a new version).
|
# when image.yml publishes a new version).
|
||||||
container:
|
container:
|
||||||
image: git.rkdr.net/mortis/ci:0.2.53@sha256:a106bd35c649fd15f027d4a4e81aa27d60b3c0377bbb6abfd73faf180f8c6f84
|
image: git.rkdr.net/mortis/ci:0.2.54@sha256:2742be4ba03f71f00b06f1d2b318e8fd3866a800247bbd7e52508dfb0da6312c
|
||||||
env:
|
env:
|
||||||
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
PIP_DISABLE_PIP_VERSION_CHECK: "1"
|
||||||
PRE_COMMIT_HOME: /opt/pre-commit
|
PRE_COMMIT_HOME: /opt/pre-commit
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
# Built collection archives and local tooling
|
# Built collection archives and local tooling
|
||||||
*.tar.gz
|
*.tar.gz
|
||||||
/.venv/
|
/.venv/
|
||||||
|
/.venv-dev/
|
||||||
/venv/
|
/venv/
|
||||||
__pycache__/
|
__pycache__/
|
||||||
*.pyc
|
*.pyc
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ extends: default
|
|||||||
|
|
||||||
ignore: |
|
ignore: |
|
||||||
.venv/**
|
.venv/**
|
||||||
|
.venv-dev/**
|
||||||
apm_modules/**
|
apm_modules/**
|
||||||
# Generated by apm install; its list indentation fails the rules below.
|
# Generated by apm install; its list indentation fails the rules below.
|
||||||
apm.lock.yaml
|
apm.lock.yaml
|
||||||
|
|||||||
@@ -34,4 +34,6 @@ GLOSSARY\\.md @Defame1297
|
|||||||
\\.claude/.* @Defame1297
|
\\.claude/.* @Defame1297
|
||||||
apm\\.yml @Defame1297
|
apm\\.yml @Defame1297
|
||||||
apm\\.lock\\.yaml @Defame1297
|
apm\\.lock\\.yaml @Defame1297
|
||||||
|
pyproject\\.toml @Defame1297
|
||||||
|
uv\\.lock @Defame1297
|
||||||
\\.mcp\\.json @Defame1297
|
\\.mcp\\.json @Defame1297
|
||||||
+6
-6
@@ -1,6 +1,6 @@
|
|||||||
lockfile_version: '4'
|
lockfile_version: '4'
|
||||||
generated_at: '2026-11-29T13:12:37.842657+00:00'
|
generated_at: '2026-12-04T21:33:07.493501+00:00'
|
||||||
apm_version: 0.38.1
|
apm_version: 0.39.3
|
||||||
manifest_targets:
|
manifest_targets:
|
||||||
- claude
|
- claude
|
||||||
dependencies:
|
dependencies:
|
||||||
@@ -220,8 +220,8 @@ dependencies:
|
|||||||
.claude/agents/plan-researcher.md: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
|
.claude/agents/plan-researcher.md: sha256:eda0457d2007cf0c6cb4745383a0369d03a26ed252d7251a1f5250003a89ef85
|
||||||
.claude/agents/plan-validator.md: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
|
.claude/agents/plan-validator.md: sha256:a56e7a710fd9e7a9dd9e2601f1f2701b98fd229f3e014bba4bda4dfe5977ecae
|
||||||
.claude/commands/next.md: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
|
.claude/commands/next.md: sha256:8e16330ec0f16dbbc86d44fca94699e33e393c9a8af76f45d3f3bd2b9c8bfa1f
|
||||||
.claude/commands/plan.md: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
|
.claude/commands/plan.md: sha256:c5216fb6c443ca9de45ad5cb69351a4e3193bcb5ffca4d59567495fcb5d7ec71
|
||||||
.claude/commands/ship.md: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
|
.claude/commands/ship.md: sha256:c3c9f516b9b01cb7f879d7d331187b12f697f73104b0eafdc813d64b73091284
|
||||||
.claude/skills/plan-track/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
.claude/skills/plan-track/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
||||||
.claude/skills/plan-track/SKILL.md: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
|
.claude/skills/plan-track/SKILL.md: sha256:fee5062c8c63b49f66368b290c8ebd8cfff744137670d0c037da1a49c455c047
|
||||||
.claude/skills/research-docs/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
.claude/skills/research-docs/LICENSE: sha256:9d3692e6b35e0e43b81e096352f11c6b884e7004d78d3dcd92768232c6704525
|
||||||
@@ -843,7 +843,7 @@ deployments:
|
|||||||
owners:
|
owners:
|
||||||
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
content_hash: sha256:2538b3dbb3860ebe93a39cad95cd5a1adcbeded19f404a84201b3e8aa7ce91c7
|
content_hash: sha256:c5216fb6c443ca9de45ad5cb69351a4e3193bcb5ffca4d59567495fcb5d7ec71
|
||||||
- kind: project-relative
|
- kind: project-relative
|
||||||
target: claude
|
target: claude
|
||||||
value: .claude/commands/ship.md
|
value: .claude/commands/ship.md
|
||||||
@@ -852,7 +852,7 @@ deployments:
|
|||||||
owners:
|
owners:
|
||||||
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
- git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
active_owner: git.rkdr.net/Mortis/Holocron/plugins/plan
|
||||||
content_hash: sha256:f108f73e60a884f46285955027fba47d6309fed6a89812948f577e27be180af8
|
content_hash: sha256:c3c9f516b9b01cb7f879d7d331187b12f697f73104b0eafdc813d64b73091284
|
||||||
- kind: project-relative
|
- kind: project-relative
|
||||||
target: claude
|
target: claude
|
||||||
value: .claude/skills/code-review
|
value: .claude/skills/code-review
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
minor_changes:
|
||||||
|
- >-
|
||||||
|
ufw - New input ``ufw_mask_nftables`` (default ``true``) and tag ``ufw_nftables``. Set the input to ``false``
|
||||||
|
on a host that loads its own ruleset through ``nftables.service``; the role never unmasks the unit.
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
bugfixes:
|
||||||
|
- >-
|
||||||
|
ufw - An upgrade of the ``nftables`` package no longer deletes the firewall rules on hosts where
|
||||||
|
``nftables.service`` is enabled. The package's postinst restarts that unit, whose stock ``/etc/nftables.conf``
|
||||||
|
begins with ``flush ruleset``, so the rules ufw and Docker loaded were gone until they reloaded. The role now
|
||||||
|
masks ``nftables.service`` without stopping it whenever ``ufw_enabled`` is true, also when the unit or the
|
||||||
|
package is absent, so the first run reports ``changed`` once. A host that loads its own ruleset through
|
||||||
|
``nftables.service`` (NAT tables or sets, for example) would lose it at the next reboot without a warning, because
|
||||||
|
a masked unit does not start: set ``ufw_mask_nftables: false`` on such a host before upgrading.
|
||||||
@@ -9,7 +9,7 @@ held by review until an offline link check exists.
|
|||||||
## The clone
|
## The clone
|
||||||
|
|
||||||
- **Run `scripts/dev-setup.sh` once per clone, and again after a change to `requirements-dev.txt`, its
|
- **Run `scripts/dev-setup.sh` once per clone, and again after a change to `requirements-dev.txt`, its
|
||||||
lock `requirements-dev.lock`, `requirements.yml` or the hook types.** It creates `.venv` with the
|
lock `requirements-dev.lock`, `requirements.yml` or the hook types.** It creates `.venv-dev` with the
|
||||||
pinned tools on the Python named in `.python-version`, installs the collections of `requirements.yml`
|
pinned tools on the Python named in `.python-version`, installs the collections of `requirements.yml`
|
||||||
into `.ansible/collections`, and installs the git hooks (pre-commit, commit-msg, pre-push) with the
|
into `.ansible/collections`, and installs the git hooks (pre-commit, commit-msg, pre-push) with the
|
||||||
virtualenv first on their `PATH`.
|
virtualenv first on their `PATH`.
|
||||||
@@ -63,6 +63,12 @@ held by review until an offline link check exists.
|
|||||||
pushed on an unmerged branch lets that branch's commands run without a prompt before anyone has
|
pushed on an unmerged branch lets that branch's commands run without a prompt before anyone has
|
||||||
reviewed it, while a `deny` or `ask` rule can only add prompts.
|
reviewed it, while a `deny` or `ask` rule can only add prompts.
|
||||||
*Held by:* review (`.claude/` is under `CODEOWNERS`).
|
*Held by:* review (`.claude/` is under `CODEOWNERS`).
|
||||||
|
- **Install [uv](https://docs.astral.sh/uv/getting-started/installation/), run `uv sync --frozen` once per
|
||||||
|
clone and again after a change to `uv.lock`, and run apm only as `uv run --frozen apm ...`** (for example
|
||||||
|
`uv run --frozen apm install`). uv keeps apm in `.venv`, apart from the tools in `.venv-dev`.
|
||||||
|
*Reason:* a bare `apm` is whatever version your machine has, and versions differ in which
|
||||||
|
`apm.lock.yaml` they accept and in what they deploy.
|
||||||
|
*Held by:* aspirational.
|
||||||
- **Every hook in the tracked `.claude/settings.json` arrives through apm; personal hooks go in
|
- **Every hook in the tracked `.claude/settings.json` arrives through apm; personal hooks go in
|
||||||
`.claude/settings.local.json`.**
|
`.claude/settings.local.json`.**
|
||||||
*Reason:* a hook nobody owns is checked by nothing.
|
*Reason:* a hook nobody owns is checked by nothing.
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ build_ignore:
|
|||||||
- .python-version
|
- .python-version
|
||||||
- .ruff_cache
|
- .ruff_cache
|
||||||
- .venv
|
- .venv
|
||||||
|
- .venv-dev
|
||||||
- .yamllint
|
- .yamllint
|
||||||
- docs
|
- docs
|
||||||
- .ansible-lint
|
- .ansible-lint
|
||||||
@@ -59,6 +60,7 @@ build_ignore:
|
|||||||
- images
|
- images
|
||||||
- scripts
|
- scripts
|
||||||
- tests/scripts
|
- tests/scripts
|
||||||
|
- pyproject.toml
|
||||||
- renovate.json
|
- renovate.json
|
||||||
- ruff.toml
|
- ruff.toml
|
||||||
- requirements-dev.txt
|
- requirements-dev.txt
|
||||||
@@ -66,6 +68,7 @@ build_ignore:
|
|||||||
- requirements-molecule.txt
|
- requirements-molecule.txt
|
||||||
- requirements-molecule.lock
|
- requirements-molecule.lock
|
||||||
- requirements.yml
|
- requirements.yml
|
||||||
|
- uv.lock
|
||||||
- gitleaks-report.json
|
- gitleaks-report.json
|
||||||
- importer_result.json
|
- importer_result.json
|
||||||
- 'roles/*/molecule'
|
- 'roles/*/molecule'
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
# distribution's python3 and ca-certificates.
|
# distribution's python3 and ca-certificates.
|
||||||
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
# - /opt/venv: requirements-dev.lock, the hashed lock of requirements-dev.txt (ansible-core, ansible-lint, pre-commit,
|
||||||
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of
|
# antsibull-changelog, galaxy-importer, reuse, molecule, proxmoxer), on the Python of
|
||||||
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv uses.
|
# .python-version (PYTHON_VERSION below), the one the lock was resolved on and a clone's .venv-dev uses.
|
||||||
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
|
# molecule is there for Lint's "Test the repository scripts" step, whose molecule tests import it; its
|
||||||
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
|
# Docker driver and community.docker are not: Molecule runs in the molecule-controller image.
|
||||||
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
# - /opt/collections: the collections of requirements.yml (the versions the roles are
|
||||||
@@ -71,7 +71,7 @@ COPY requirements-dev.txt requirements-dev.lock requirements.yml .pre-commit-con
|
|||||||
|
|
||||||
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
|
# The interpreters come first: /opt/venv is built from the pinned one (PYTHON_VERSION, kept equal to
|
||||||
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
|
# .python-version and to the lock header by `check_image_versions.py pins`), not from the distribution's
|
||||||
# python3, so the tools run on the Python the lock was resolved on and a clone's .venv uses.
|
# python3, so the tools run on the Python the lock was resolved on and a clone's .venv-dev uses.
|
||||||
# uv only lives in the build stage (its own venv): the final image keeps the interpreters it
|
# uv only lives in the build stage (its own venv): the final image keeps the interpreters it
|
||||||
# downloaded, not the installer. The distribution's python3 only bootstraps uv.
|
# downloaded, not the installer. The distribution's python3 only bootstraps uv.
|
||||||
RUN python3 -m venv /opt/uv-venv \
|
RUN python3 -m venv /opt/uv-venv \
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
# Pins apm for contributors (docs/contributing/setup.md). The Lint and Build tools are pinned in requirements-dev.txt.
|
||||||
|
[project]
|
||||||
|
name = "kamino"
|
||||||
|
version = "0"
|
||||||
|
# ruff reads this floor too: a higher one makes it reformat existing files.
|
||||||
|
requires-python = ">=3.11"
|
||||||
|
|
||||||
|
[dependency-groups]
|
||||||
|
dev = ["apm-cli==0.39.3"]
|
||||||
|
|
||||||
|
[tool.uv]
|
||||||
|
package = false
|
||||||
@@ -196,7 +196,6 @@
|
|||||||
"pypi"
|
"pypi"
|
||||||
],
|
],
|
||||||
"matchPackageNames": [
|
"matchPackageNames": [
|
||||||
"apm-cli",
|
|
||||||
"antsibull-changelog",
|
"antsibull-changelog",
|
||||||
"galaxy-importer",
|
"galaxy-importer",
|
||||||
"reuse",
|
"reuse",
|
||||||
|
|||||||
+6
-1180
File diff suppressed because it is too large.
Load diff
@@ -1,5 +1,5 @@
|
|||||||
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally:
|
# Pinned tooling for Lint and Build, used by CI (.gitea/workflows) and locally:
|
||||||
# python3 -m venv .venv && . .venv/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
# python3 -m venv .venv-dev && . .venv-dev/bin/activate && pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||||
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
|
# This file holds the direct pins; requirements-dev.lock is their hashed lock (every transitive
|
||||||
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
|
# package too, with the sha256 of each release file) and is what gets installed; pip refuses an
|
||||||
# install in which the two files disagree. Renovate bumps a pin here and regenerates the lock
|
# install in which the two files disagree. Renovate bumps a pin here and regenerates the lock
|
||||||
@@ -18,6 +18,3 @@ molecule==26.11.1
|
|||||||
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
# proxmoxer: the controller-side library community.proxmox's modules import (they refuse anything below 2.3),
|
||||||
# so lint runs where a consumer's controller would.
|
# so lint runs where a consumer's controller would.
|
||||||
proxmoxer==2.3.0
|
proxmoxer==2.3.0
|
||||||
# apm-cli: for changing apm.yml (run apm install, commit the lock). Keep it at 0.36.1 or later (#252):
|
|
||||||
# before 0.29.0, `apm audit --ci` compares the whole .claude/settings.json and fails on any hand-written key.
|
|
||||||
apm-cli==0.39.1
|
|
||||||
+5
-2
@@ -29,6 +29,7 @@ Main entry point:
|
|||||||
| `ufw_manage_rules` | `true` | no | Skip the `ufw_rules` schema check, the lock-out guard and rule application when false. Before-rules validation and `before.rules`, defaults and enable still run (gated on `ufw_enabled`). |
|
| `ufw_manage_rules` | `true` | no | Skip the `ufw_rules` schema check, the lock-out guard and rule application when false. Before-rules validation and `before.rules`, defaults and enable still run (gated on `ufw_enabled`). |
|
||||||
| `ufw_defaults` | `incoming: deny`, `outgoing: allow`, `routed: deny` | no | Default policies. All three keys are read, so override all of them. |
|
| `ufw_defaults` | `incoming: deny`, `outgoing: allow`, `routed: deny` | no | Default policies. All three keys are read, so override all of them. |
|
||||||
| `ufw_logging` | `"on"` | no | UFW logging level. |
|
| `ufw_logging` | `"on"` | no | UFW logging level. |
|
||||||
|
| `ufw_mask_nftables` | `true` | no | Mask `nftables.service` without stopping it, so a package upgrade cannot flush the rules ufw loaded (see Notes). Set false on a host that loads its own ruleset through that unit. Gated on `ufw_enabled`. |
|
||||||
| `ufw_require_ssh_allow` | `true` | no | Enable the SSH lock-out guard. |
|
| `ufw_require_ssh_allow` | `true` | no | Enable the SSH lock-out guard. |
|
||||||
| `ufw_ssh_port` | `ansible_port` or 22 | no | TCP port the guard looks for. |
|
| `ufw_ssh_port` | `ansible_port` or 22 | no | TCP port the guard looks for. |
|
||||||
| `ufw_rules` | `[]` | no | Base rule list: `rule` (allow, deny, reject, limit), `port`, `proto`, `from`, `to`, `interface`, `direction`, `comment`, `delete` (see Notes). |
|
| `ufw_rules` | `[]` | no | Base rule list: `rule` (allow, deny, reject, limit), `port`, `proto`, `from`, `to`, `interface`, `direction`, `comment`, `delete` (see Notes). |
|
||||||
@@ -117,7 +118,7 @@ An **orphan** is a rule tagged `ansible-ufw[<owner>:<key>]` whose owner is neith
|
|||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
|
|
||||||
`ufw` (everything), `ufw_install`, `ufw_sysctl`, `ufw_aggregate`, `ufw_validate`, `ufw_before_rules`, `ufw_defaults`, `ufw_rules`, `ufw_enable`.
|
`ufw` (everything), `ufw_install`, `ufw_sysctl`, `ufw_aggregate`, `ufw_validate`, `ufw_nftables`, `ufw_before_rules`, `ufw_defaults`, `ufw_rules`, `ufw_enable`.
|
||||||
|
|
||||||
Skipping `ufw_aggregate` leaves the lists the later tasks read (`ufw_aggregated_rules`, `ufw_aggregated_before_rules`) undefined or stale, so do not select a later tag alone.
|
Skipping `ufw_aggregate` leaves the lists the later tasks read (`ufw_aggregated_rules`, `ufw_aggregated_before_rules`) undefined or stale, so do not select a later tag alone.
|
||||||
|
|
||||||
@@ -144,10 +145,11 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
|||||||
- Verify then reads `ufw status verbose` and `ufw show added`: ufw is active with default deny incoming, the base rules are loaded, the deleted rule is gone, the manual and SSH rules are untouched, the service rules carry their owner tag, stale and orphan rules are deleted only where purging was on and only when they cannot carry SSH.
|
- Verify then reads `ufw status verbose` and `ufw show added`: ufw is active with default deny incoming, the base rules are loaded, the deleted rule is gone, the manual and SSH rules are untouched, the service rules carry their owner tag, stale and orphan rules are deleted only where purging was on and only when they cannot carry SSH.
|
||||||
- Verify checks `before.rules`: the loopback accept, the INVALID-state drop behind its logging rule and in its place among the input rules.
|
- Verify checks `before.rules`: the loopback accept, the INVALID-state drop behind its logging rule and in its place among the input rules.
|
||||||
- Verify runs `service_rules` under the `check_mode` keyword and checks that the rule list did not change.
|
- Verify runs `service_rules` under the `check_mode` keyword and checks that the rule list did not change.
|
||||||
|
- Verify checks the nftables mask: prepare installs `nftables`, enables and starts its unit; after the converge the unit is masked and still active, ufw's chains survive `apt-get install --reinstall nftables` (whose postinst runs the upgrade restart), the same reinstall with the mask removed flushes them (the control), and after the package is purged and the mask removed the role masks the absent unit again without failing.
|
||||||
|
|
||||||
The scenario `molecule/check-absent/` runs on the same two platforms: prepare purges ufw and refreshes the APT cache, then `check` runs the main entry point and `service_rules` under `--check`, which must pass with ufw not installed. Nothing is applied.
|
The scenario `molecule/check-absent/` runs on the same two platforms: prepare purges ufw and refreshes the APT cache, then `check` runs the main entry point and `service_rules` under `--check`, which must pass with ufw not installed. Nothing is applied.
|
||||||
|
|
||||||
Not covered: `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set, and `orphan_rules` runs in check mode only under `--check` (the `check` steps), not under the `check_mode` keyword.
|
Not covered: `ufw_mask_nftables: false` is never set, `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set, and `orphan_rules` runs in check mode only under `--check` (the `check` steps), not under the `check_mode` keyword.
|
||||||
|
|
||||||
## Notes
|
## Notes
|
||||||
|
|
||||||
@@ -158,5 +160,6 @@ Not covered: `ufw_before_rules` entries and `ufw_sysctl_overrides` are never set
|
|||||||
- Rule schema is asserted before anything changes: `rule` must be allow, deny, reject or limit, `port` a positive integer, `proto` tcp or udp, and each rule needs `port`, `from`, `to` or `interface`.
|
- Rule schema is asserted before anything changes: `rule` must be allow, deny, reject or limit, `port` a positive integer, `proto` tcp or udp, and each rule needs `port`, `from`, `to` or `interface`.
|
||||||
- UFW is only re-enabled when `ufw status verbose` shows it inactive or the logging line differs, because the module rewrites rules and re-applies sysctl on every call.
|
- UFW is only re-enabled when `ufw status verbose` shows it inactive or the logging line differs, because the module rewrites rules and re-applies sysctl on every call.
|
||||||
- The `Reload UFW` handler runs `ufw reload`.
|
- The `Reload UFW` handler runs `ufw reload`.
|
||||||
|
- nftables: when `nftables.service` is enabled (a preset can do that), the `nftables` package's postinst restarts it on upgrade (`dh_installsystemd --no-enable --no-start --restart-after-upgrade` emits `deb-systemd-invoke try-restart`), and both the restart and the unit's `ExecStop=/usr/sbin/nft flush ruleset` delete every rule ufw (and Docker) loaded, since the stock `/etc/nftables.conf` begins with `flush ruleset`. The role masks the unit and does not stop it, so nothing is flushed during the run. systemd refuses every job but a stop on a masked unit, so the postinst's restart fails before anything runs and the postinst ignores the failure (`|| true`); at boot the unit is not started either. The mask also applies when the unit or the package is absent, so a later install cannot enable it; the package's postinst removes only a mask its own helper created. The role never unmasks: with `ufw_mask_nftables: false` or `ufw_enabled: false` an existing mask stays. `--check` reports the mask without applying it. When `/etc/systemd/system/nftables.service` is a unit file of its own rather than a link, `systemctl mask` refuses with "already exists" and the play fails; set `ufw_mask_nftables: false` on such a host.
|
||||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without ufw the preview reports the install and skips the configuration (`before.rules`, default policies, rules, enable), which needs the `ufw` binary.
|
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without ufw the preview reports the install and skips the configuration (`before.rules`, default policies, rules, enable), which needs the `ufw` binary.
|
||||||
- `no_log` is not used: the role handles no secrets.
|
- `no_log` is not used: the role handles no secrets.
|
||||||
@@ -9,6 +9,10 @@ ufw_defaults:
|
|||||||
|
|
||||||
ufw_logging: "on"
|
ufw_logging: "on"
|
||||||
|
|
||||||
|
# Mask nftables.service (not stopped), so a restart by a package upgrade cannot flush the rules
|
||||||
|
# ufw loaded. false: leave the unit alone, for hosts that load their own ruleset through it.
|
||||||
|
ufw_mask_nftables: true
|
||||||
|
|
||||||
# Lock-out guard: with a deny/reject incoming default the play refuses to run
|
# Lock-out guard: with a deny/reject incoming default the play refuses to run
|
||||||
# unless an allow/limit rule for this TCP port is in the rule list, since the
|
# unless an allow/limit rule for this TCP port is in the rule list, since the
|
||||||
# default is applied before the rules and a missing rule cuts the SSH session.
|
# default is applied before the rules and a missing rule cuts the SSH session.
|
||||||
|
|||||||
@@ -49,6 +49,18 @@ argument_specs:
|
|||||||
choices: ["on", "off", low, medium, high, full]
|
choices: ["on", "off", low, medium, high, full]
|
||||||
description:
|
description:
|
||||||
- UFW logging setting. UFW is only re-enabled when it is inactive or its current logging line differs from this value.
|
- UFW logging setting. UFW is only re-enabled when it is inactive or its current logging line differs from this value.
|
||||||
|
ufw_mask_nftables:
|
||||||
|
type: bool
|
||||||
|
default: true
|
||||||
|
description:
|
||||||
|
- >-
|
||||||
|
When true (and C(ufw_enabled) is true) C(nftables.service) is masked, without being stopped, also when the
|
||||||
|
unit or the C(nftables) package is absent. A restart of the enabled unit, which the package runs on upgrade,
|
||||||
|
loads the stock C(/etc/nftables.conf) that begins with C(flush ruleset), and its stop flushes the ruleset,
|
||||||
|
which deletes the rules ufw loaded. A masked unit is never started, also not at boot.
|
||||||
|
- >-
|
||||||
|
Set false on hosts that load their own ruleset through C(nftables.service). The role never unmasks the unit,
|
||||||
|
so switching to false leaves an existing mask in place.
|
||||||
ufw_require_ssh_allow:
|
ufw_require_ssh_allow:
|
||||||
type: bool
|
type: bool
|
||||||
default: true
|
default: true
|
||||||
|
|||||||
@@ -84,3 +84,40 @@
|
|||||||
- {port: "40:50", comment: "ansible-ufw[svc_c:6666666663]: range"}
|
- {port: "40:50", comment: "ansible-ufw[svc_c:6666666663]: range"}
|
||||||
loop_control:
|
loop_control:
|
||||||
loop_var: ufw_prepare_rule
|
loop_var: ufw_prepare_rule
|
||||||
|
|
||||||
|
# An enabled, active nftables.service with the stock /etc/nftables.conf, as a preset leaves
|
||||||
|
# it; verify.yml checks that the role's mask keeps a package upgrade from flushing ufw's rules.
|
||||||
|
- name: Install nftables
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: present
|
||||||
|
|
||||||
|
# A policy-rc.d that refuses actions would make the postinst skip the restart verify.yml tests.
|
||||||
|
- name: Let maintainer scripts act on units as on a host
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /usr/sbin/policy-rc.d
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
# ProtectSystem and ProtectHome need a mount namespace, which needs CAP_SYS_ADMIN; without
|
||||||
|
# it the unit fails with 226/NAMESPACE in this unprivileged container.
|
||||||
|
- name: Create the drop-in directory of nftables.service
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/system/nftables.service.d
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Disable the namespace-based sandboxing of nftables.service for the container
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/systemd/system/nftables.service.d/molecule.conf
|
||||||
|
mode: "0644"
|
||||||
|
content: |
|
||||||
|
[Service]
|
||||||
|
ProtectSystem=no
|
||||||
|
ProtectHome=no
|
||||||
|
|
||||||
|
- name: Enable and start nftables.service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
daemon_reload: true
|
||||||
@@ -521,3 +521,110 @@
|
|||||||
- ufw_verify_chk_after.stdout_lines == ufw_verify_chk_before.stdout_lines
|
- ufw_verify_chk_after.stdout_lines == ufw_verify_chk_before.stdout_lines
|
||||||
- ufw_verify_chk_after.stdout_lines | select('search', 'svc_chk|7701') | list | length == 0
|
- ufw_verify_chk_after.stdout_lines | select('search', 'svc_chk|7701') | list | length == 0
|
||||||
quiet: true
|
quiet: true
|
||||||
|
|
||||||
|
# prepare.yml left nftables.service enabled and active. The package's postinst runs
|
||||||
|
# `deb-systemd-invoke try-restart nftables.service` on upgrade (and on a reinstall, which passes
|
||||||
|
# the old version too); the stock config and ExecStop flush the ruleset. The masked case runs
|
||||||
|
# first, then a control without the mask proves the reinstall reaches the unit here, then the
|
||||||
|
# absent-package case. Last, because the control flushes ufw's rules.
|
||||||
|
- name: The nftables mask keeps a package upgrade from flushing the rules
|
||||||
|
hosts: all
|
||||||
|
gather_facts: false
|
||||||
|
vars:
|
||||||
|
ufw_verify_nft_reinstall:
|
||||||
|
- apt-get
|
||||||
|
- install
|
||||||
|
- --reinstall
|
||||||
|
- -y
|
||||||
|
- -o
|
||||||
|
- Dpkg::Options::=--force-confold
|
||||||
|
- nftables
|
||||||
|
tasks:
|
||||||
|
# A mask request in check mode changes nothing and returns the unit's properties.
|
||||||
|
- name: Read the state of nftables.service
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_unit
|
||||||
|
|
||||||
|
- name: The role masked the unit and did not stop it
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_unit is not changed
|
||||||
|
- ufw_verify_nft_unit.status.LoadState == 'masked'
|
||||||
|
- ufw_verify_nft_unit.status.ActiveState == 'active'
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Reinstall nftables while the unit is masked
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: "{{ ufw_verify_nft_reinstall }}"
|
||||||
|
environment: {DEBIAN_FRONTEND: noninteractive}
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Read the iptables rules after the masked reinstall
|
||||||
|
ansible.builtin.command: iptables -S
|
||||||
|
register: ufw_verify_nft_masked_rules
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: The rules of ufw survived the reinstall
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_masked_rules.stdout_lines | select('search', '^-N ufw-user-input$') | list | length == 1
|
||||||
|
- ufw_verify_nft_masked_rules.stdout_lines | select('search', '^-A ufw-user-input .*--dport 22 ') | list | length > 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Remove the mask for the control case
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: false
|
||||||
|
|
||||||
|
- name: Reinstall nftables while the unit is enabled and active
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv: "{{ ufw_verify_nft_reinstall }}"
|
||||||
|
environment: {DEBIAN_FRONTEND: noninteractive}
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Read the iptables rules after the unmasked reinstall
|
||||||
|
ansible.builtin.command: iptables -S
|
||||||
|
register: ufw_verify_nft_unmasked_rules
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Without the mask the reinstall flushed the rules of ufw
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that: ufw_verify_nft_unmasked_rules.stdout_lines | select('search', '^-N ufw-user-input$') | list | length == 0
|
||||||
|
quiet: true
|
||||||
|
|
||||||
|
- name: Purge nftables
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: absent
|
||||||
|
purge: true
|
||||||
|
|
||||||
|
- name: Read the state of nftables.service with the package gone
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_gone
|
||||||
|
|
||||||
|
- name: Run the role on a host without the nftables package
|
||||||
|
ansible.builtin.include_role:
|
||||||
|
name: mortis.kamino.ufw
|
||||||
|
vars:
|
||||||
|
ufw_rules:
|
||||||
|
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
||||||
|
|
||||||
|
- name: Read the state of nftables.service after the role
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
check_mode: true
|
||||||
|
register: ufw_verify_nft_absent
|
||||||
|
|
||||||
|
- name: The role masked the absent unit without failing
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ufw_verify_nft_gone is changed
|
||||||
|
- ufw_verify_nft_absent is not changed
|
||||||
|
quiet: true
|
||||||
@@ -35,6 +35,10 @@
|
|||||||
ansible.builtin.import_tasks: validate.yml
|
ansible.builtin.import_tasks: validate.yml
|
||||||
tags: [ufw, ufw_validate]
|
tags: [ufw, ufw_validate]
|
||||||
|
|
||||||
|
- name: Import UFW nftables task
|
||||||
|
ansible.builtin.import_tasks: nftables.yml
|
||||||
|
tags: [ufw, ufw_nftables]
|
||||||
|
|
||||||
- name: Import UFW before rules task
|
- name: Import UFW before rules task
|
||||||
ansible.builtin.import_tasks: before_rules.yml
|
ansible.builtin.import_tasks: before_rules.yml
|
||||||
tags: [ufw, ufw_before_rules]
|
tags: [ufw, ufw_before_rules]
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
---
|
||||||
|
# A restart of nftables.service (on a package upgrade) flushes the rules ufw loaded. Mask only:
|
||||||
|
# a stop would flush them now. README Notes has the detail.
|
||||||
|
- name: Mask nftables.service without stopping it
|
||||||
|
become: true
|
||||||
|
ansible.builtin.systemd_service:
|
||||||
|
name: nftables.service
|
||||||
|
masked: true
|
||||||
|
when:
|
||||||
|
- ufw_enabled
|
||||||
|
- ufw_mask_nftables
|
||||||
@@ -19,7 +19,7 @@ cd "$root"
|
|||||||
|
|
||||||
for tool in ansible ansible-test; do
|
for tool in ansible ansible-test; do
|
||||||
if ! command -v "$tool" >/dev/null 2>&1; then
|
if ! command -v "$tool" >/dev/null 2>&1; then
|
||||||
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv/bin)" >&2
|
echo "error: $tool is not on PATH; run scripts/dev-setup.sh and use its virtualenv (.venv-dev/bin)" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ allow list. It fails the build for:
|
|||||||
ansible-galaxy dereferences FILE symlinks while building, so a symlink to a file reaches
|
ansible-galaxy dereferences FILE symlinks while building, so a symlink to a file reaches
|
||||||
the archive as a regular file with the target's content and this check cannot see it. The
|
the archive as a regular file with the target's content and this check cannot see it. The
|
||||||
`Refuse symlinks in the source tree` step of .gitea/workflows/build.yml is the only guard
|
`Refuse symlinks in the source tree` step of .gitea/workflows/build.yml is the only guard
|
||||||
against that. Its `find` prunes ./.venv and ./.git only because both are in galaxy.yml
|
against that. Its `find` prunes ./.git, ./.venv and ./.venv-dev only because they are in galaxy.yml
|
||||||
`build_ignore` (or excluded by ansible-galaxy itself, as .git is): the two lists must stay
|
`build_ignore` (or excluded by ansible-galaxy itself, as .git is): the two lists must stay
|
||||||
in step, and tests/scripts/test_check_tarball.py fails when a pruned directory is not
|
in step, and tests/scripts/test_check_tarball.py fails when a pruned directory is not
|
||||||
ignored by the build.
|
ignored by the build.
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ set -euo pipefail
|
|||||||
|
|
||||||
# The repository is derived from this script's own location (symlinks resolved), never
|
# The repository is derived from this script's own location (symlinks resolved), never
|
||||||
# from the caller's working directory: running it from another repository must not
|
# from the caller's working directory: running it from another repository must not
|
||||||
# create or remove that repository's .venv.
|
# create or remove that repository's .venv-dev.
|
||||||
script="$(readlink -f "${BASH_SOURCE[0]}")"
|
script="$(readlink -f "${BASH_SOURCE[0]}")"
|
||||||
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
|
root="$(git -C "$(dirname "$script")/.." rev-parse --show-toplevel)"
|
||||||
cd "$root"
|
cd "$root"
|
||||||
@@ -122,19 +122,19 @@ if still="$(git -C "$root" config --get core.hooksPath)" && [ -n "$still" ]; the
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
# A virtualenv made by an older Python is rebuilt rather than reused.
|
# A virtualenv made by an older Python is rebuilt rather than reused.
|
||||||
if [ -x .venv/bin/python ] && ! .venv/bin/python -c "$py_ok" 2>/dev/null; then
|
if [ -x .venv-dev/bin/python ] && ! .venv-dev/bin/python -c "$py_ok" 2>/dev/null; then
|
||||||
rm -rf "$root/.venv"
|
rm -rf "$root/.venv-dev"
|
||||||
fi
|
fi
|
||||||
[ -x .venv/bin/python ] || "$python" -m venv .venv
|
[ -x .venv-dev/bin/python ] || "$python" -m venv .venv-dev
|
||||||
.venv/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
.venv-dev/bin/pip install --quiet --disable-pip-version-check --require-hashes -r requirements-dev.lock -r requirements-dev.txt
|
||||||
.venv/bin/pre-commit install --install-hooks
|
.venv-dev/bin/pre-commit install --install-hooks
|
||||||
|
|
||||||
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
|
# The collections of requirements.yml, exactly as pinned, into this clone (.ansible/ is ignored by
|
||||||
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
|
# git and by the Collection build). ANSIBLE_COLLECTIONS_PATH is set to the target for the install:
|
||||||
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
|
# a copy found elsewhere (~/.ansible/collections) would be skipped as already installed.
|
||||||
collections="$root/.ansible/collections"
|
collections="$root/.ansible/collections"
|
||||||
mkdir -p "$collections"
|
mkdir -p "$collections"
|
||||||
ANSIBLE_COLLECTIONS_PATH="$collections" .venv/bin/ansible-galaxy collection install \
|
ANSIBLE_COLLECTIONS_PATH="$collections" .venv-dev/bin/ansible-galaxy collection install \
|
||||||
-r requirements.yml -p "$collections"
|
-r requirements.yml -p "$collections"
|
||||||
|
|
||||||
marker="# kamino-dev-setup: virtualenv first on PATH"
|
marker="# kamino-dev-setup: virtualenv first on PATH"
|
||||||
@@ -150,7 +150,7 @@ for hook in pre-commit commit-msg pre-push; do
|
|||||||
{
|
{
|
||||||
head -n 1 "$file"
|
head -n 1 "$file"
|
||||||
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
|
# %q shell-quotes the path: a repository path with spaces, quotes or $(...) is data.
|
||||||
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv/bin"):\"\$PATH\""
|
printf '%s\n' "$marker" "export PATH=$(printf '%q' "$root/.venv-dev/bin"):\"\$PATH\""
|
||||||
tail -n +2 "$file"
|
tail -n +2 "$file"
|
||||||
} > "$tmp"
|
} > "$tmp"
|
||||||
cat "$tmp" > "$file" # keeps the file mode of the hook
|
cat "$tmp" > "$file" # keeps the file mode of the hook
|
||||||
@@ -179,4 +179,4 @@ else
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Done: git commit now runs the hooks with the tools in $root/.venv/bin and the collections in $collections."
|
echo "Done: git commit now runs the hooks with the tools in $root/.venv-dev/bin and the collections in $collections."
|
||||||
@@ -11,7 +11,7 @@
|
|||||||
# Needs the network (PyPI) and the Python of .python-version (python<MINOR>; KAMINO_PYTHON overrides it): the
|
# Needs the network (PyPI) and the Python of .python-version (python<MINOR>; KAMINO_PYTHON overrides it): the
|
||||||
# header of the lock records it, and check_image_versions.py pins fails when it differs.
|
# header of the lock records it, and check_image_versions.py pins fails when it differs.
|
||||||
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
|
# pip and pip-tools are installed, at the pinned versions below, into a throwaway virtualenv, never
|
||||||
# into the project's .venv. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
|
# into the project's .venv-dev. pip is pinned too: pip-tools breaks on newer pip releases (7.5.2 on pip 26). Commit
|
||||||
# the lock with its requirements file; pip refuses an install of the two when they disagree
|
# the lock with its requirements file; pip refuses an install of the two when they disagree
|
||||||
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`).
|
# (`pip install --require-hashes -r requirements-dev.lock -r requirements-dev.txt`).
|
||||||
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that
|
# The pins are not hash-checked themselves: they come from PyPI over TLS, like the pip that
|
||||||
|
|||||||
@@ -92,6 +92,8 @@ IGNORED = (
|
|||||||
"ruff.toml",
|
"ruff.toml",
|
||||||
"apm.yml",
|
"apm.yml",
|
||||||
"apm.lock.yaml",
|
"apm.lock.yaml",
|
||||||
|
"pyproject.toml",
|
||||||
|
"uv.lock",
|
||||||
".claude/*",
|
".claude/*",
|
||||||
"tests/sanity/*",
|
"tests/sanity/*",
|
||||||
"tests/scripts/*",
|
"tests/scripts/*",
|
||||||
|
|||||||
@@ -267,7 +267,7 @@ class CraftedTarballTest(unittest.TestCase):
|
|||||||
REPO,
|
REPO,
|
||||||
src,
|
src,
|
||||||
ignore=shutil.ignore_patterns(
|
ignore=shutil.ignore_patterns(
|
||||||
".git", ".venv", "__pycache__", "output", "*.tar.gz"
|
".git", ".venv", ".venv-dev", "__pycache__", "output", "*.tar.gz"
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
out = pathlib.Path(self.tmp.name) / "dist"
|
out = pathlib.Path(self.tmp.name) / "dist"
|
||||||
|
|||||||
@@ -192,7 +192,7 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
proc = self.run_setup(repo, KAMINO_PYTHON=str(wrong))
|
proc = self.run_setup(repo, KAMINO_PYTHON=str(wrong))
|
||||||
self.assertNotEqual(proc.returncode, 0)
|
self.assertNotEqual(proc.returncode, 0)
|
||||||
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
||||||
self.assertFalse((repo / ".venv").exists())
|
self.assertFalse((repo / ".venv-dev").exists())
|
||||||
|
|
||||||
def test_an_interpreter_of_another_minor_is_refused_and_the_pinned_one_accepted(
|
def test_an_interpreter_of_another_minor_is_refused_and_the_pinned_one_accepted(
|
||||||
self,
|
self,
|
||||||
@@ -201,10 +201,10 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
proc = self.run_setup(repo, STUB_PY_MINOR="3.12")
|
proc = self.run_setup(repo, STUB_PY_MINOR="3.12")
|
||||||
self.assertNotEqual(proc.returncode, 0)
|
self.assertNotEqual(proc.returncode, 0)
|
||||||
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
self.assertIn("is not Python 3.13 (.python-version)", proc.stderr)
|
||||||
self.assertFalse((repo / ".venv").exists())
|
self.assertFalse((repo / ".venv-dev").exists())
|
||||||
proc = self.run_setup(repo, STUB_PY_MINOR="3.13")
|
proc = self.run_setup(repo, STUB_PY_MINOR="3.13")
|
||||||
self.assertEqual(proc.returncode, 0, proc.stderr)
|
self.assertEqual(proc.returncode, 0, proc.stderr)
|
||||||
self.assertTrue((repo / ".venv").is_dir())
|
self.assertTrue((repo / ".venv-dev").is_dir())
|
||||||
|
|
||||||
def test_a_missing_pin_file_is_refused_with_a_message(self) -> None:
|
def test_a_missing_pin_file_is_refused_with_a_message(self) -> None:
|
||||||
repo = self.make_repo()
|
repo = self.make_repo()
|
||||||
@@ -228,6 +228,30 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
text = self.hook(repo, name).read_text()
|
text = self.hook(repo, name).read_text()
|
||||||
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
self.assertIn("# kamino-dev-setup: virtualenv first on PATH", text)
|
||||||
self.assertEqual(self.hooks_z(repo), b"")
|
self.assertEqual(self.hooks_z(repo), b"")
|
||||||
|
self.assertFalse((repo / ".venv").exists())
|
||||||
|
|
||||||
|
def test_a_rerun_moves_the_hooks_of_an_older_setup_to_venv_dev(self) -> None:
|
||||||
|
repo = self.make_repo()
|
||||||
|
kept = repo / ".venv" / "kept"
|
||||||
|
kept.parent.mkdir()
|
||||||
|
kept.write_text("")
|
||||||
|
names = ("pre-commit", "commit-msg", "pre-push")
|
||||||
|
for name in names:
|
||||||
|
hook = self.hook(repo, name)
|
||||||
|
hook.parent.mkdir(exist_ok=True)
|
||||||
|
hook.write_text(
|
||||||
|
"#!/usr/bin/env bash\n"
|
||||||
|
"# kamino-dev-setup: virtualenv first on PATH\n"
|
||||||
|
f'export PATH={repo}/.venv/bin:"$PATH"\n'
|
||||||
|
)
|
||||||
|
hook.chmod(0o755)
|
||||||
|
result = self.run_setup(repo)
|
||||||
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
|
for name in names:
|
||||||
|
text = self.hook(repo, name).read_text()
|
||||||
|
self.assertIn(f'export PATH={repo}/.venv-dev/bin:"$PATH"\n', text)
|
||||||
|
self.assertNotIn("/.venv/bin", text)
|
||||||
|
self.assertTrue(kept.exists())
|
||||||
|
|
||||||
def test_a_missing_tea_warns_and_setup_succeeds(self) -> None:
|
def test_a_missing_tea_warns_and_setup_succeeds(self) -> None:
|
||||||
repo = self.make_repo()
|
repo = self.make_repo()
|
||||||
@@ -403,12 +427,12 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
self.git(other, "init", "--quiet")
|
self.git(other, "init", "--quiet")
|
||||||
result = self.run_setup(repo, cwd=other)
|
result = self.run_setup(repo, cwd=other)
|
||||||
self.assertEqual(result.returncode, 0, result.stderr)
|
self.assertEqual(result.returncode, 0, result.stderr)
|
||||||
self.assertFalse((other / ".venv").exists())
|
self.assertFalse((other / ".venv-dev").exists())
|
||||||
self.assertEqual(
|
self.assertEqual(
|
||||||
os.listdir(other / ".git" / "hooks"),
|
os.listdir(other / ".git" / "hooks"),
|
||||||
[n for n in os.listdir(other / ".git" / "hooks") if n.endswith(".sample")],
|
[n for n in os.listdir(other / ".git" / "hooks") if n.endswith(".sample")],
|
||||||
)
|
)
|
||||||
self.assertTrue((repo / ".venv").is_dir())
|
self.assertTrue((repo / ".venv-dev").is_dir())
|
||||||
self.assertTrue(self.hook(repo).exists())
|
self.assertTrue(self.hook(repo).exists())
|
||||||
|
|
||||||
def test_crafted_repository_path_is_not_executed(self) -> None:
|
def test_crafted_repository_path_is_not_executed(self) -> None:
|
||||||
@@ -428,7 +452,7 @@ class DevSetupTest(unittest.TestCase):
|
|||||||
self.assertEqual(hook.returncode, 0, hook.stderr)
|
self.assertEqual(hook.returncode, 0, hook.stderr)
|
||||||
lines = hook.stdout.splitlines()
|
lines = hook.stdout.splitlines()
|
||||||
self.assertEqual(lines[0], "hook-ran")
|
self.assertEqual(lines[0], "hook-ran")
|
||||||
self.assertTrue(lines[1].startswith(f"{repo}/.venv/bin:"), lines[1])
|
self.assertTrue(lines[1].startswith(f"{repo}/.venv-dev/bin:"), lines[1])
|
||||||
for place in (workdir, repo, self.tmp, Path.cwd()):
|
for place in (workdir, repo, self.tmp, Path.cwd()):
|
||||||
self.assertFalse((place / "PWNED").exists(), place)
|
self.assertFalse((place / "PWNED").exists(), place)
|
||||||
self.assertFalse((place / "PWNED2").exists(), place)
|
self.assertFalse((place / "PWNED2").exists(), place)
|
||||||
|
|||||||
@@ -217,6 +217,10 @@ class SelectTest(unittest.TestCase):
|
|||||||
chosen, _reason = self.select(["requirements-dev.txt", "requirements-dev.lock"])
|
chosen, _reason = self.select(["requirements-dev.txt", "requirements-dev.lock"])
|
||||||
self.assertEqual(chosen, [])
|
self.assertEqual(chosen, [])
|
||||||
|
|
||||||
|
def test_the_apm_pin_selects_nothing(self):
|
||||||
|
chosen, _reason = self.select(["pyproject.toml", "uv.lock"])
|
||||||
|
self.assertEqual(chosen, [])
|
||||||
|
|
||||||
def test_molecule_requirements_select_everything(self):
|
def test_molecule_requirements_select_everything(self):
|
||||||
# An ansible-core or molecule bump there changes the tools every scenario runs with.
|
# An ansible-core or molecule bump there changes the tools every scenario runs with.
|
||||||
for path in ("requirements-molecule.txt", "requirements-molecule.lock"):
|
for path in ("requirements-molecule.txt", "requirements-molecule.lock"):
|
||||||
|
|||||||
Reference in new issue
Block a user