Merge branch 'main' into feat/fail2ban-reload
This commit is contained in:
commit
9d31fd9461
24 files changed
+303
-8
No files matched your search
@@ -87,7 +87,7 @@ jobs:
|
||||
dockerfile: Dockerfile
|
||||
job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
|
||||
- name: ci
|
||||
version: 0.2.36
|
||||
version: 0.2.37
|
||||
subpath: ""
|
||||
dockerfile: images/ci/Dockerfile
|
||||
job_image: ubuntu:26.04@sha256:d66b366dac61b575bee2aef07e9c26e8070096fbe84a3d4d3eb0da069b5d76db
|
||||
|
||||
@@ -126,6 +126,16 @@ repos:
|
||||
require_serial: true
|
||||
fail_fast: true
|
||||
|
||||
# apm compile (target claude), a tool's project init or a skill can create a CLAUDE.md, and
|
||||
# the failure is silent: the agent gets no guidance and no error.
|
||||
- id: refuse-claude-md
|
||||
name: Refuse CLAUDE.md files
|
||||
description: refuse CLAUDE.md, CLAUDE.local.md and .claude/CLAUDE.md at any depth
|
||||
entry: a CLAUDE.md file makes Claude Code ignore every AGENTS.md; delete it
|
||||
language: fail
|
||||
files: (^|/)(\.claude/)?CLAUDE(\.local)?\.md$
|
||||
stages: ['pre-commit']
|
||||
|
||||
- repo: meta
|
||||
hooks:
|
||||
- id: check-hooks-apply
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
docker - ``docker_apt_arch`` now defaults to an empty value that derives the apt architecture from the host (``x86_64`` gives ``amd64``,
|
||||
``aarch64`` gives ``arm64``) instead of always writing ``amd64``, so an arm64 host no longer needs an override. A value set in the inventory
|
||||
is used as before. A host with any other architecture fails the play with a message that names ``docker_apt_arch`` instead of getting an
|
||||
``amd64`` source line that its apt cannot use; set ``docker_apt_arch`` for such a host.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
system_baseline - Add ``system_baseline_unattended_upgrade_package_blacklist`` (list of regular expressions, default empty). A non-empty
|
||||
list is written to ``/etc/apt/apt.conf.d/90unattended-upgrades-blacklist`` as ``Unattended-Upgrade::Package-Blacklist``, so unattended-upgrades
|
||||
leaves those packages alone on a host whose kernel or drivers must not change. An empty list removes the file.
|
||||
@@ -4,7 +4,7 @@ Installs Docker Engine from the upstream Docker APT repository, optionally updat
|
||||
|
||||
## Supported platforms
|
||||
|
||||
Ubuntu. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The default architecture is `amd64`. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||
Ubuntu. The key and repository URLs point at `download.docker.com/linux/ubuntu`, and the source line uses `ansible_distribution_release`. The apt architecture is derived from the host (`x86_64` gives `amd64`, `aarch64` gives `arm64`); any other architecture fails the play until `docker_apt_arch` is set. A limited molecule scenario covers the role's own logic (see [Tests](#tests)); the real Docker Engine is not tested.
|
||||
|
||||
## Requirements and run order
|
||||
|
||||
@@ -25,7 +25,7 @@ Ubuntu. The key and repository URLs point at `download.docker.com/linux/ubuntu`,
|
||||
| `docker_apt_list_path` | `/etc/apt/sources.list.d/docker.list` | no | APT source file. |
|
||||
| `docker_gpg_url` | `https://download.docker.com/linux/ubuntu/gpg` | no | Key URL. |
|
||||
| `docker_repo_base_url` | `https://download.docker.com/linux/ubuntu` | no | Repository base URL. |
|
||||
| `docker_apt_arch` | `amd64` | no | Architecture in the APT source. |
|
||||
| `docker_apt_arch` | derived from the host | no | Architecture in the APT source. Empty derives it (`x86_64` gives `amd64`, `aarch64` gives `arm64`); another architecture fails until this is set. A value set here is always used; lowercase letters and digits only. |
|
||||
| `docker_service` | `docker` | no | systemd unit name. |
|
||||
| `docker_group` | `docker` | no | Group for `docker_users`. |
|
||||
| `docker_users` | `[]` | no | Users added to the group. |
|
||||
|
||||
@@ -13,8 +13,9 @@ docker_apt_list_path: /etc/apt/sources.list.d/docker.list
|
||||
docker_gpg_url: https://download.docker.com/linux/ubuntu/gpg
|
||||
docker_repo_base_url: https://download.docker.com/linux/ubuntu
|
||||
|
||||
# Override per host if a host is not amd64.
|
||||
docker_apt_arch: amd64
|
||||
# Architecture written into the APT source. Empty (the default) derives it from the host: x86_64 gives amd64, aarch64 gives arm64, any
|
||||
# other architecture fails the play, so set it here (for example armhf) when Docker publishes one for it.
|
||||
docker_apt_arch: ""
|
||||
|
||||
docker_service: docker
|
||||
docker_group: docker
|
||||
|
||||
@@ -56,9 +56,12 @@ argument_specs:
|
||||
- Base URL of the repository. The source line uses C(ansible_distribution_release) and the C(stable) component.
|
||||
docker_apt_arch:
|
||||
type: str
|
||||
default: amd64
|
||||
default: ""
|
||||
description:
|
||||
- Architecture written into the APT source. Override per host if a host is not amd64.
|
||||
- >-
|
||||
Architecture written into the APT source. Empty (the default) derives it from the host: C(x86_64) gives C(amd64), C(aarch64)
|
||||
gives C(arm64). Any other host architecture fails the play, so set this to the name Docker publishes for it. Lowercase letters
|
||||
and digits only. A value set here is always used.
|
||||
docker_service:
|
||||
type: str
|
||||
default: docker
|
||||
|
||||
@@ -59,3 +59,27 @@
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_remove' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# The architecture is written into the one-line apt source, so a value with a space or a bracket is refused before anything
|
||||
# changes. The derived default is covered by the converge above and verify.yml (the container is x86_64, so the source says amd64).
|
||||
- name: A docker_apt_arch value that would corrupt the apt source is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
docker_apt_arch: "bad arch"
|
||||
tasks:
|
||||
- name: Apply the role with a bad architecture
|
||||
block:
|
||||
- name: Include the role
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.docker
|
||||
- name: Fail when the bad architecture was accepted
|
||||
ansible.builtin.fail:
|
||||
msg: MOLECULE-ACCEPTED
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- "'MOLECULE-ACCEPTED' not in ansible_failed_result.msg | default('')"
|
||||
- "'docker_apt_arch' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
@@ -17,6 +17,7 @@
|
||||
- /srv/docker-stub-repo/docker.asc
|
||||
register: docker_verify_files
|
||||
|
||||
# amd64 because the Molecule container is x86_64: the role derives the architecture from the host now.
|
||||
- name: The source line carries the arch, the keyring and the release
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
ansible.builtin.copy:
|
||||
dest: "{{ docker_apt_list_path }}"
|
||||
content: |
|
||||
deb [arch={{ docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
|
||||
deb [arch={{ __docker_apt_arch }} signed-by={{ docker_keyring_path }}] {{ docker_repo_base_url }} {{ ansible_distribution_release }} stable
|
||||
mode: "0644"
|
||||
tags: [docker, install]
|
||||
|
||||
|
||||
@@ -1,4 +1,9 @@
|
||||
---
|
||||
- name: Validate inputs
|
||||
ansible.builtin.import_tasks: validate.yml
|
||||
when: not (docker_remove | default(false) | bool)
|
||||
tags: always
|
||||
|
||||
- name: Remove Docker (explicit only)
|
||||
ansible.builtin.include_tasks: remove.yml
|
||||
when: docker_remove | default(false) | bool
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
---
|
||||
# Fact-computing and assertion only, before any task changes the host. A removal does not write the apt source, so it does not need the architecture.
|
||||
- name: Work out the apt architecture
|
||||
ansible.builtin.set_fact:
|
||||
__docker_apt_arch: >-
|
||||
{{ docker_apt_arch | default('', true) or __docker_arch_by_fact[ansible_facts['architecture'] | default('')] | default('', true) }}
|
||||
tags: always
|
||||
|
||||
# The value is written into the one-line apt source (deb [arch=... signed-by=...]): a space or a bracket would corrupt it.
|
||||
- name: Check the apt architecture
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __docker_apt_arch is match('^[a-z0-9]+\Z')
|
||||
fail_msg: >-
|
||||
{% if docker_apt_arch | default('', true) | length > 0 %}
|
||||
docker_apt_arch '{{ docker_apt_arch }}' is not a valid apt architecture name: use the name Docker publishes (for example amd64 or arm64),
|
||||
lowercase letters and digits only.
|
||||
{% else %}
|
||||
The host architecture '{{ ansible_facts['architecture'] | default('unknown') }}' has no known Docker apt architecture (x86_64 and aarch64 do).
|
||||
Set docker_apt_arch to the name Docker publishes for it, for example armhf.
|
||||
{% endif %}
|
||||
quiet: true
|
||||
tags: always
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
# Constants, not inputs: the Docker apt architecture for each ansible_facts['architecture'] the role derives it for. docker_apt_arch
|
||||
# overrides it for any other architecture.
|
||||
__docker_arch_by_fact:
|
||||
x86_64: amd64
|
||||
aarch64: arm64
|
||||
@@ -34,6 +34,7 @@ templating error instead of the role's own message.
|
||||
| `system_baseline_apt_periodic_settings` | from profile | no | Keys for `20auto-upgrades` |
|
||||
| `system_baseline_unattended_upgrade_settings` | from profile | no | Keys for `50unattended-upgrades` |
|
||||
| `system_baseline_unattended_upgrade_origins` | from profile | no | Pinned `Origins-Pattern` entries; `[]` keeps the distribution default (see below) |
|
||||
| `system_baseline_unattended_upgrade_package_blacklist` | `[]` | no | Packages unattended-upgrades must not touch, as regular expressions (see below) |
|
||||
| `system_baseline_sysctl_hardening` | from profile | no | List of `name` and `value` sysctl pairs |
|
||||
| `system_baseline_secure_tmp_mounts` | from profile | no | Paths remounted as tmpfs with `noexec,nosuid,nodev` |
|
||||
| `system_baseline_journal_max_use` | `200M` | no | Upper bound of the persistent journal (journald `SystemMaxUse`). |
|
||||
@@ -133,6 +134,26 @@ A profile's `unattended_upgrade_origins` list pins the origins unattended-upgrad
|
||||
- A file in `/etc/apt/apt.conf.d` that sorts after `90unattended-upgrades-origins` can still add origins, and so can `/etc/apt/apt.conf`, which apt reads after `apt.conf.d`.
|
||||
- Check the merged result on a host with `apt-config dump | grep -E 'Unattended-Upgrade::(Origins-Pattern|Allowed-Origins)'`.
|
||||
|
||||
## Unattended-upgrades package blacklist
|
||||
|
||||
`system_baseline_unattended_upgrade_package_blacklist` keeps individual packages out of unattended-upgrades, for a host whose kernel or drivers must not change (for example one with hardware passthrough). Each entry is a regular expression matched against the package name, so `linux-image-.*` covers every kernel image; anchor an entry (`^name$`) when it must not match longer names too. A non-empty list is written to `/etc/apt/apt.conf.d/90unattended-upgrades-blacklist` as `Unattended-Upgrade::Package-Blacklist`. apt appends list entries across files, so the entries are added to those of `50unattended-upgrades`, which is not edited. An empty list removes the file. An entry may not hold a double quote, a backslash or a line break.
|
||||
|
||||
- Example for Proxmox VE hosts: packages that should only ever change through a deliberate `apt dist-upgrade` (Proxmox's documented way to update, because its packages add and remove dependencies). The `pve` profile already pins unattended-upgrades to Debian's origins, so these never come from the Proxmox repository through unattended-upgrades; the list keeps that true if the pin is ever removed or widened. Adjust it to the repositories you use:
|
||||
|
||||
```yaml
|
||||
system_baseline_unattended_upgrade_package_blacklist:
|
||||
- "^pve-.*" # pve-manager, pve-kernel-*, pve-qemu-kvm, pve-container ...
|
||||
- "^libpve-.*"
|
||||
- "^proxmox-.*" # proxmox-ve, proxmox-kernel-*, proxmox-backup-client ...
|
||||
- "^qemu-server$"
|
||||
- "^ceph.*"
|
||||
- "^corosync$"
|
||||
```
|
||||
|
||||
- Like the other unattended-upgrades settings, it is applied only when `unattended-upgrades` is in the profile's packages.
|
||||
- This is unattended-upgrades only. The role's own apt upgrade (`update` tag, and the `update` entry point) is not limited by it; set `system_baseline_update: false` for a host that is patched by a separate flow.
|
||||
- Check the merged result on a host with `apt-config dump | grep Package-Blacklist`.
|
||||
|
||||
## Notes
|
||||
|
||||
- The `pve` profile has no `ufw`; the `ubuntu_*` profiles install it and `fail2ban`.
|
||||
|
||||
@@ -230,5 +230,8 @@ system_baseline_apt_periodic_settings: "{{ system_baseline_profile.apt_periodic_
|
||||
system_baseline_unattended_upgrade_settings: "{{ system_baseline_profile.unattended_upgrade_settings }}"
|
||||
# default([]): a system_baseline_profiles written before this key existed keeps the distribution default.
|
||||
system_baseline_unattended_upgrade_origins: "{{ system_baseline_profile.unattended_upgrade_origins | default([]) }}"
|
||||
# Packages unattended-upgrades must not touch, on top of the profile: a per-host list, empty by default (see README, "Unattended-upgrades
|
||||
# package blacklist"). Entries are regular expressions matched against the package name.
|
||||
system_baseline_unattended_upgrade_package_blacklist: []
|
||||
system_baseline_sysctl_hardening: "{{ system_baseline_profile.sysctl_hardening }}"
|
||||
system_baseline_secure_tmp_mounts: "{{ system_baseline_profile.secure_tmp_mounts }}"
|
||||
@@ -102,6 +102,19 @@ argument_specs:
|
||||
default: true
|
||||
description:
|
||||
- Reboot when C(/var/run/reboot-required) exists after the run.
|
||||
system_baseline_unattended_upgrade_package_blacklist:
|
||||
type: list
|
||||
elements: str
|
||||
default: []
|
||||
description:
|
||||
- >-
|
||||
Packages unattended-upgrades must leave alone, for a host whose kernel or drivers must not change. Entries are regular
|
||||
expressions matched against the package name, so C(linux-image-.*) covers every kernel image; anchor an entry (C(^name$))
|
||||
when it must not match longer names too.
|
||||
- >-
|
||||
A non-empty list is written to C(/etc/apt/apt.conf.d/90unattended-upgrades-blacklist) as C(Unattended-Upgrade::Package-Blacklist).
|
||||
apt appends list entries across files, so these are added to those of C(50unattended-upgrades). An empty list removes the file.
|
||||
An entry may not hold a double quote, a backslash or a line break.
|
||||
system_baseline_update:
|
||||
type: bool
|
||||
default: true
|
||||
|
||||
@@ -19,6 +19,21 @@
|
||||
that: "'is invalid' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
|
||||
# A quote, a null item and a bare string (not a list) each stop the run: the bare string would otherwise be split into one-character
|
||||
# patterns, and the null item would become an empty pattern that matches every package.
|
||||
- name: A bad package blacklist is refused
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
tasks:
|
||||
- name: Refuse each bad value
|
||||
ansible.builtin.include_tasks: tasks/refuse_blacklist.yml
|
||||
vars:
|
||||
system_baseline_refused_blacklist: "{{ item }}"
|
||||
loop:
|
||||
- ['bad"name']
|
||||
- [null]
|
||||
- linux-image-.*
|
||||
|
||||
- name: Converge the LXC profile
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
---
|
||||
# One refusal: the role must stop on validation, before it changes anything, with a message that names the variable.
|
||||
- name: Run the role with a bad package blacklist
|
||||
block:
|
||||
- name: Include system_baseline
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_unattended_upgrade_package_blacklist: "{{ system_baseline_refused_blacklist }}"
|
||||
- name: Unreachable when validation works
|
||||
ansible.builtin.fail:
|
||||
msg: system_baseline ran with an invalid package blacklist
|
||||
rescue:
|
||||
- name: The validation stopped the play
|
||||
ansible.builtin.assert:
|
||||
that: "'system_baseline_unattended_upgrade_package_blacklist must be' in ansible_failed_result.msg | default('')"
|
||||
quiet: true
|
||||
@@ -270,3 +270,84 @@
|
||||
- system_baseline_verify_apt_config_restored.stdout_lines | select('match', 'Unattended-Upgrade::Allowed-Origins::\s') | list | length > 0
|
||||
- system_baseline_verify_apt_config_restored.stdout is not search('origin=Debian')
|
||||
quiet: true
|
||||
|
||||
# The package blacklist: written and parsed by apt as a list, left alone by a second run, removed by an empty list. Here and not in
|
||||
# converge, because converge runs the default (empty) list.
|
||||
- name: The unattended-upgrades package blacklist is written, kept and removed
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars:
|
||||
system_baseline_verify_blacklist: ["linux-image-.*", "nvidia-.*"]
|
||||
tasks:
|
||||
- name: Run the unattended-upgrades tasks with a blacklist
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: unattended_upgrades
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_unattended_upgrade_package_blacklist: "{{ system_baseline_verify_blacklist }}"
|
||||
|
||||
- name: Stat the blacklist drop-in
|
||||
ansible.builtin.stat:
|
||||
path: /etc/apt/apt.conf.d/90unattended-upgrades-blacklist
|
||||
register: system_baseline_verify_blacklist_first
|
||||
|
||||
- name: Dump the merged apt configuration
|
||||
ansible.builtin.command: apt-config dump
|
||||
register: system_baseline_verify_blacklist_dump
|
||||
changed_when: false
|
||||
|
||||
- name: Apt reads both entries as a list
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- system_baseline_verify_blacklist_first.stat.exists
|
||||
- >-
|
||||
system_baseline_verify_blacklist_dump.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list ==
|
||||
['Unattended-Upgrade::Package-Blacklist:: "linux-image-.*";', 'Unattended-Upgrade::Package-Blacklist:: "nvidia-.*";']
|
||||
quiet: true
|
||||
|
||||
- name: Run the same tasks again
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: unattended_upgrades
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_unattended_upgrade_package_blacklist: "{{ system_baseline_verify_blacklist }}"
|
||||
|
||||
- name: Stat the blacklist drop-in again
|
||||
ansible.builtin.stat:
|
||||
path: /etc/apt/apt.conf.d/90unattended-upgrades-blacklist
|
||||
register: system_baseline_verify_blacklist_second
|
||||
|
||||
- name: A second run does not rewrite the file
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- system_baseline_verify_blacklist_second.stat.checksum == system_baseline_verify_blacklist_first.stat.checksum
|
||||
- system_baseline_verify_blacklist_second.stat.mtime == system_baseline_verify_blacklist_first.stat.mtime
|
||||
quiet: true
|
||||
|
||||
- name: Run the same tasks with an empty blacklist
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: unattended_upgrades
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_unattended_upgrade_package_blacklist: []
|
||||
|
||||
- name: Stat the blacklist drop-in after the empty list
|
||||
ansible.builtin.stat:
|
||||
path: /etc/apt/apt.conf.d/90unattended-upgrades-blacklist
|
||||
register: system_baseline_verify_blacklist_removed
|
||||
|
||||
- name: Dump the merged apt configuration after the empty list
|
||||
ansible.builtin.command: apt-config dump
|
||||
register: system_baseline_verify_blacklist_dump_removed
|
||||
changed_when: false
|
||||
|
||||
- name: The file is gone and apt lists no blacklisted package
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- not system_baseline_verify_blacklist_removed.stat.exists
|
||||
- system_baseline_verify_blacklist_dump_removed.stdout_lines | select('match', 'Unattended-Upgrade::Package-Blacklist::\s') | list == []
|
||||
quiet: true
|
||||
tags: always
|
||||
@@ -40,6 +40,23 @@
|
||||
state: absent
|
||||
when: system_baseline_unattended_upgrade_origins | length == 0
|
||||
|
||||
- name: Keep packages out of unattended-upgrades
|
||||
become: true
|
||||
ansible.builtin.template:
|
||||
src: unattended-upgrades-blacklist.j2
|
||||
dest: /etc/apt/apt.conf.d/90unattended-upgrades-blacklist
|
||||
owner: root
|
||||
group: root
|
||||
mode: "0644"
|
||||
when: system_baseline_unattended_upgrade_package_blacklist | length > 0
|
||||
|
||||
- name: Remove the package blacklist when none is set
|
||||
become: true
|
||||
ansible.builtin.file:
|
||||
path: /etc/apt/apt.conf.d/90unattended-upgrades-blacklist
|
||||
state: absent
|
||||
when: system_baseline_unattended_upgrade_package_blacklist | length == 0
|
||||
|
||||
- name: Validate unattended-upgrades config
|
||||
become: true
|
||||
ansible.builtin.command: unattended-upgrades --dry-run --debug
|
||||
|
||||
@@ -35,6 +35,21 @@
|
||||
when: system_baseline_tmux_autostart | bool
|
||||
tags: always
|
||||
|
||||
# Each package pattern is written inside a double-quoted apt.conf string, like the origins below: the same characters are refused.
|
||||
- name: Validate the unattended-upgrades package blacklist
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- system_baseline_unattended_upgrade_package_blacklist is sequence
|
||||
- system_baseline_unattended_upgrade_package_blacklist is not string
|
||||
- system_baseline_unattended_upgrade_package_blacklist is not mapping
|
||||
- system_baseline_unattended_upgrade_package_blacklist | select('string') | select('match', '^[^"\\\\\n\r]+\Z') | list | length
|
||||
== system_baseline_unattended_upgrade_package_blacklist | length
|
||||
fail_msg: >-
|
||||
system_baseline_unattended_upgrade_package_blacklist must be a list of non-empty one-line strings without a double quote
|
||||
or a backslash.
|
||||
quiet: true
|
||||
tags: always
|
||||
|
||||
# Each origin is written inside a double-quoted apt.conf string: a quote or a line break would end it, a backslash could escape.
|
||||
- name: Validate the unattended-upgrades origins
|
||||
ansible.builtin.assert:
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
// Managed by Ansible (mortis.kamino.system_baseline, tasks/unattended_upgrades.yml). Do not edit: the next run overwrites it.
|
||||
// apt appends list entries across apt.conf.d files, so these packages are added to Unattended-Upgrade::Package-Blacklist of
|
||||
// 50unattended-upgrades. Entries are regular expressions matched against the package name.
|
||||
Unattended-Upgrade::Package-Blacklist {
|
||||
{% for package in system_baseline_unattended_upgrade_package_blacklist %}
|
||||
"{{ package }}";
|
||||
{% endfor %}
|
||||
};
|
||||
@@ -89,6 +89,8 @@ FORBIDDEN = [
|
||||
"*.env.*",
|
||||
"*/.env*",
|
||||
".env*",
|
||||
# Contributor rules: a consumer's agent reading an installed role would load them.
|
||||
"*/agents.md",
|
||||
]
|
||||
# Names Windows treats as devices, with or without an extension (and with trailing spaces).
|
||||
WINDOWS_RESERVED = {
|
||||
|
||||
@@ -70,6 +70,22 @@ class TarballTest(unittest.TestCase):
|
||||
self.assertEqual(len(found), 1, name)
|
||||
self.assertIn("forbidden pattern", found[0], name)
|
||||
|
||||
def test_agents_md_is_refused_at_any_depth(self):
|
||||
for name in (
|
||||
"roles/AGENTS.md",
|
||||
"roles/x/AGENTS.md",
|
||||
"roles/x/templates/Agents.md",
|
||||
):
|
||||
found = check_tarball.problems([name])
|
||||
self.assertEqual(len(found), 1, name)
|
||||
self.assertIn("forbidden pattern", found[0], name)
|
||||
self.assertEqual(
|
||||
check_tarball.problems(
|
||||
["roles/x/README.md", "roles/x/files/agents_notes.md"]
|
||||
),
|
||||
[],
|
||||
)
|
||||
|
||||
def test_ambiguous_names_are_rejected(self):
|
||||
cases = {
|
||||
"roles/a/x ": "ends in a space or a dot",
|
||||
|
||||
Reference in new issue
Block a user