Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7bc3cc6bdf |
No files matched your search
@@ -1,4 +0,0 @@
|
||||
---
|
||||
trivial:
|
||||
- >-
|
||||
system_baseline - Purge the unwanted packages that are installed in one apt call instead of one call per package.
|
||||
@@ -0,0 +1,6 @@
|
||||
---
|
||||
minor_changes:
|
||||
- >-
|
||||
traefik - The prerequisites install refreshes the APT cache only when it is older than an hour;
|
||||
before, every run refreshed it. A consumer who adds an APT source just before the role must
|
||||
refresh the cache first.
|
||||
@@ -134,8 +134,8 @@ The scenario `molecule/default/` runs in CI only, on two platforms: `${MOLECULE_
|
||||
- Verify checks the installed and removed packages, the journal size cap, the apt settings in `20auto-upgrades` and `50unattended-upgrades`, the locale, and that systemd loaded the `apt-daily.service` timeout.
|
||||
- Verify checks the tmux snippet: root-owned, valid shell, the session and quoted window command, no effect without a terminal, a session name or window command ending in a newline refused, and the file removed when autostart is off.
|
||||
- Verify refuses bad items in `system_baseline_extra_packages` and `system_baseline_extra_remove_packages` (whitespace, a null, an empty string, a trailing minus, upper case, a bare string) and a package that one input installs and another purges; converge applies the `ubuntu_lxc` profile with `jq` as an extra package and `ed` as an extra removal; verify checks that `jq` is installed, `ed` is gone and the profile's packages are still there, and that an extra `tmux` installs the snippet where a flat list without it installs none.
|
||||
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, that the connection is reset afterwards, and that the vzdump guard is imported before the upgrade, whose `when` reads the guard's fact: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||
- Verify runs the vzdump guard in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`); six run the guard's task file alone and the `ubuntu_lxc` case runs the whole `update` entry point. Each case asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
|
||||
- Verify also checks that a bad `system_baseline_apt_tmpdir` (under `/tmp` or `/var/tmp`, relative, with `..`, empty) is refused in the main flow and in the `update` entry point. It reads `tasks/update.yml` and checks that the scratch directory is created with mode `0700`, that both apt tasks set `TMPDIR` to it, and that the connection is reset afterwards: the scenario skips the `update` tag, so the upgrade itself never runs there.
|
||||
- Verify runs the `update` entry point in check mode on the Ubuntu container with `system_baseline_system_type: pve` and a `pvesh` stub, in seven cases (a running, a finished or no vzdump task, the input off, `ubuntu_lxc`), and asserts the fact that decides the upgrade and that `pvesh` was run, with `--source active`, only when it should be. It does not assert that the apt task itself was skipped. The stub stands for the real answer, which no CI image has.
|
||||
- Verify ends by running the role once with `system_baseline_journal_max_use: ""` after removing the drop-in, and asserts that no drop-in is written and that `systemd-journald` was not restarted.
|
||||
- Verify runs the `reboot` entry point with `system_baseline_reboot_if_required: false`, without and with `/var/run/reboot-required`, and checks the fact and that the host did not reboot.
|
||||
- The `pve` origins pin is applied to the Ubuntu container and read back with `apt-config dump`, then removed again. The package blacklist is written, read back as a list, left alone by a second run and removed by an empty list.
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
- name: Converge the LXC profile
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
vars:
|
||||
system_baseline_system_type: ubuntu_lxc
|
||||
system_baseline_extra_packages: [jq]
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
---
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case.answer, the role's tasks_from file (the guard alone unless the
|
||||
# case names update) runs in check mode, and the fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the
|
||||
# case expects. Kept outside the role's own tasks: no CI image is a Proxmox node, so the stub stands for the real `pvesh get` answer.
|
||||
# One case of the vzdump guard: a pvesh stub answers with system_baseline_case_answer, the update entry point runs in check mode, and the
|
||||
# fact that decides the upgrade, and whether pvesh was asked at all, are compared with what the case expects. Kept outside the role's own tasks:
|
||||
# no CI image is a Proxmox node, so the stub stands for the real `pvesh get /nodes/<node>/tasks` answer.
|
||||
- name: Write the pvesh stub
|
||||
check_mode: false
|
||||
ansible.builtin.copy:
|
||||
@@ -14,9 +14,8 @@
|
||||
{{ system_baseline_case.answer | to_json }}
|
||||
JSON
|
||||
|
||||
- name: Create the apt scratch directory, which a check mode run of the update entry point does not
|
||||
- name: Create the apt scratch directory, which a check mode run does not
|
||||
check_mode: false
|
||||
when: system_baseline_case.tasks_from | default('vzdump_guard') == 'update'
|
||||
ansible.builtin.file:
|
||||
path: /var/cache/system-baseline-apt-tmp
|
||||
state: directory
|
||||
@@ -27,13 +26,13 @@
|
||||
path: /var/tmp/pvesh-calls
|
||||
state: absent
|
||||
|
||||
- name: Run the case's tasks in check mode
|
||||
- name: Run the update entry point in check mode
|
||||
check_mode: true
|
||||
block:
|
||||
- name: Include system_baseline, tasks_from {{ system_baseline_case.tasks_from | default('vzdump_guard') }}
|
||||
- name: Include system_baseline, tasks_from update
|
||||
ansible.builtin.include_role:
|
||||
name: mortis.kamino.system_baseline
|
||||
tasks_from: "{{ system_baseline_case.tasks_from | default('vzdump_guard') }}"
|
||||
tasks_from: update
|
||||
vars:
|
||||
system_baseline_system_type: "{{ system_baseline_case.type }}"
|
||||
system_baseline_skip_upgrade_during_vzdump: "{{ system_baseline_case.input }}"
|
||||
|
||||
@@ -464,19 +464,6 @@
|
||||
- system_baseline_verify_update_tasks is search('(?m)^ ansible.builtin.meta:\sreset_connection$')
|
||||
quiet: true
|
||||
|
||||
# The guard cases below run vzdump_guard.yml alone, so this holds the wiring: the guard is imported before the upgrade, and the upgrade
|
||||
# task's when reads the guard's fact.
|
||||
- name: The vzdump guard is imported before the upgrade, and the upgrade waits on its fact
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- >-
|
||||
system_baseline_verify_update_tasks is search('(?ms)^ ansible\.builtin\.import_tasks:\svzdump_guard\.yml$'
|
||||
~ '.*^- name:\sUpdate & upgrade apt packages$')
|
||||
- >-
|
||||
system_baseline_verify_update_tasks is search('(?m)^- name:\sUpdate & upgrade apt packages\n(?: .*\n)*?'
|
||||
~ ' - not \(__system_baseline_vzdump_running \| default\(false\)\)$')
|
||||
quiet: true
|
||||
|
||||
# The reboot entry point is a supported interface: with system_baseline_reboot_if_required
|
||||
# false it only sets system_baseline_reboot_required. Here and not in converge, because it
|
||||
# creates and removes the marker file, which the idempotence run would report as a change.
|
||||
@@ -484,7 +471,6 @@
|
||||
- name: The reboot entry point only computes the fact when told not to reboot
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
tasks:
|
||||
- name: Remove the reboot marker
|
||||
ansible.builtin.file:
|
||||
@@ -799,8 +785,7 @@
|
||||
tags: always
|
||||
|
||||
# The vzdump guard (system_baseline_skip_upgrade_during_vzdump): a running backup is a vzdump task without an endtime. With the input off, or on
|
||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI. The cases run the guard
|
||||
# alone; the last one runs the update entry point, so it still runs end to end in check mode.
|
||||
# a system type other than pve, pvesh is never run. Only the decision is asserted: the upgrade itself is not run in CI.
|
||||
- name: The vzdump guard skips the upgrade only for a running backup on a pve node
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
@@ -816,7 +801,7 @@
|
||||
- {type: pve, input: true, running: false, asked: true, answer: [{type: qmstart, upid: b, starttime: 1}]}
|
||||
- {type: pve, input: true, running: false, asked: true, answer: []}
|
||||
- {type: pve, input: false, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}], tasks_from: update}
|
||||
- {type: ubuntu_lxc, input: true, running: false, asked: false, answer: [{type: vzdump, upid: a, starttime: 1}]}
|
||||
|
||||
# An empty system_baseline_journal_max_use leaves journald alone: with the drop-in gone, the role neither writes it again nor restarts
|
||||
# systemd-journald. It runs last, because it applies the role with its defaults (the converge's tmux autostart and apt-daily timeout are
|
||||
@@ -825,7 +810,6 @@
|
||||
- name: An empty journal size cap leaves journald alone
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_subset: [min]
|
||||
tasks:
|
||||
- name: Remove the drop-in and its directory
|
||||
ansible.builtin.file:
|
||||
|
||||
@@ -12,13 +12,11 @@
|
||||
manager: auto
|
||||
become: true
|
||||
|
||||
# One apt call for every unwanted package that is installed, skipped when none is.
|
||||
- name: Remove unnecessary packages if installed
|
||||
ansible.builtin.package:
|
||||
name: "{{ __system_baseline_purge_present }}"
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
purge: true
|
||||
vars:
|
||||
__system_baseline_purge_present: "{{ __system_baseline_purge_packages | select('in', ansible_facts.packages) | list }}"
|
||||
when: __system_baseline_purge_present | length > 0
|
||||
loop: "{{ __system_baseline_purge_packages }}"
|
||||
when: item in ansible_facts.packages
|
||||
become: true
|
||||
@@ -21,9 +21,57 @@
|
||||
mode: "0700"
|
||||
become: true
|
||||
|
||||
# import_tasks, not include_tasks: the update tag, the caller's when and __system_baseline_main_flow must reach the guard's tasks.
|
||||
- name: Decide whether a vzdump backup holds back the upgrade
|
||||
ansible.builtin.import_tasks: vzdump_guard.yml
|
||||
# Opt-in guard (system_baseline_skip_upgrade_during_vzdump, pve only): an upgrade can restart Proxmox services while a backup holds a snapshot
|
||||
# of a guest, so the upgrade waits for the next run when this node has a vzdump task without an end time. Both tasks read state only, so
|
||||
# they run in check mode too; they are skipped where the upgrade is (a dry run of the main flow). `localhost` is the node's own alias, so no
|
||||
# node name and no gathered facts are needed. --source active lists the running tasks: the default, archive, holds only finished ones. The
|
||||
# fact is set on every run, so a guard that is off or skipped never inherits the answer of an earlier run in the same play.
|
||||
- name: List the recent Proxmox tasks of this node
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- pvesh
|
||||
- get
|
||||
- /nodes/localhost/tasks
|
||||
- --source
|
||||
- active
|
||||
- --limit
|
||||
- "0"
|
||||
- --output-format
|
||||
- json
|
||||
register: __system_baseline_pve_tasks
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
become: true
|
||||
when:
|
||||
- system_baseline_skip_upgrade_during_vzdump | bool
|
||||
- system_baseline_system_type | default('') == 'pve'
|
||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||
|
||||
- name: Check that pvesh answered with a list of tasks
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_pve_tasks.stdout | from_json is sequence
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not string
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not mapping
|
||||
fail_msg: pvesh did not answer with a JSON list of tasks, so the role cannot tell whether a backup is running.
|
||||
quiet: true
|
||||
when: __system_baseline_pve_tasks is not skipped
|
||||
|
||||
- name: Note whether a vzdump backup is running on this node
|
||||
ansible.builtin.set_fact:
|
||||
__system_baseline_vzdump_running: >-
|
||||
{{ __system_baseline_pve_tasks is not skipped
|
||||
and (__system_baseline_pve_tasks.stdout | from_json
|
||||
| selectattr('type', 'equalto', 'vzdump')
|
||||
| rejectattr('endtime', 'defined')
|
||||
| list | length) > 0 }}
|
||||
|
||||
- name: Skip the upgrade while a vzdump backup is running
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Skipping the apt upgrade on {{ inventory_hostname }}: a vzdump task is running on this node. Run the update again after the backup
|
||||
has finished.
|
||||
when: __system_baseline_vzdump_running | default(false)
|
||||
|
||||
# safe is the apt module's name for the plain upgrade (apt-get upgrade --with-new-pkgs), what `true` meant here before; dist runs
|
||||
# apt-get dist-upgrade (profile key apt_upgrade, `pve` by default).
|
||||
|
||||
@@ -1,52 +0,0 @@
|
||||
---
|
||||
# Opt-in guard (system_baseline_skip_upgrade_during_vzdump, pve only): an upgrade can restart Proxmox services while a backup holds a snapshot
|
||||
# of a guest, so the upgrade waits for the next run when this node has a vzdump task without an end time. Both tasks read state only, so
|
||||
# they run in check mode too; they are skipped where the upgrade is (a dry run of the main flow). `localhost` is the node's own alias, so no
|
||||
# node name and no gathered facts are needed. --source active lists the running tasks: the default, archive, holds only finished ones. The
|
||||
# fact is set on every run, so a guard that is off or skipped never inherits the answer of an earlier run in the same play.
|
||||
- name: List the recent Proxmox tasks of this node
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- pvesh
|
||||
- get
|
||||
- /nodes/localhost/tasks
|
||||
- --source
|
||||
- active
|
||||
- --limit
|
||||
- "0"
|
||||
- --output-format
|
||||
- json
|
||||
register: __system_baseline_pve_tasks
|
||||
changed_when: false
|
||||
check_mode: false
|
||||
become: true
|
||||
when:
|
||||
- system_baseline_skip_upgrade_during_vzdump | bool
|
||||
- system_baseline_system_type | default('') == 'pve'
|
||||
- not (ansible_check_mode and __system_baseline_main_flow | default(false))
|
||||
|
||||
- name: Check that pvesh answered with a list of tasks
|
||||
ansible.builtin.assert:
|
||||
that:
|
||||
- __system_baseline_pve_tasks.stdout | from_json is sequence
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not string
|
||||
- __system_baseline_pve_tasks.stdout | from_json is not mapping
|
||||
fail_msg: pvesh did not answer with a JSON list of tasks, so the role cannot tell whether a backup is running.
|
||||
quiet: true
|
||||
when: __system_baseline_pve_tasks is not skipped
|
||||
|
||||
- name: Note whether a vzdump backup is running on this node
|
||||
ansible.builtin.set_fact:
|
||||
__system_baseline_vzdump_running: >-
|
||||
{{ __system_baseline_pve_tasks is not skipped
|
||||
and (__system_baseline_pve_tasks.stdout | from_json
|
||||
| selectattr('type', 'equalto', 'vzdump')
|
||||
| rejectattr('endtime', 'defined')
|
||||
| list | length) > 0 }}
|
||||
|
||||
- name: Skip the upgrade while a vzdump backup is running
|
||||
ansible.builtin.debug:
|
||||
msg: >-
|
||||
Skipping the apt upgrade on {{ inventory_hostname }}: a vzdump task is running on this node. Run the update again after the backup
|
||||
has finished.
|
||||
when: __system_baseline_vzdump_running | default(false)
|
||||
@@ -80,14 +80,14 @@ Update or remove: pass `-e traefik_update=true`, or `-e "traefik_remove=true tra
|
||||
|
||||
## Tests
|
||||
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and the converge downloads the real Traefik release from GitHub. Converge runs `mortis.kamino.ufw`, then the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
|
||||
The `default` molecule scenario runs in CI only, on two platforms: `${MOLECULE_IMAGE}` (Ubuntu 24.04) and `${MOLECULE_IMAGE_2604}` (Ubuntu 26.04). It needs outbound network: the role installs packages with apt and the converge downloads the real Traefik release from GitHub. Prepare runs `mortis.kamino.ufw`, so converge runs only the role. It runs `check` before the converge (on a fresh host) and after it (on the configured host). Verify covers:
|
||||
|
||||
- The input guards, first: one play expects the failure message containing `unauthenticated Traefik dashboard` (the dashboard guard: enabled without valid `user:hash` users); the next expects `collides with the middleware`, raised by the dashboard-auth collision assert, which runs whenever users are set, also with the dashboard off.
|
||||
- The install: the pinned version runs, and only the binary is left from the archive.
|
||||
- Files: `traefik.env` mode 0600 owned by root, `dynamic.yml` mode 0600 owned by `traefik`, `traefik.yml` mode 0600, the binary mode 0755; the logrotate configuration, which `logrotate --debug` parses.
|
||||
- Rendering: the ACME resolvers render when set and are absent when empty; the dashboard is off by default with the extra app routed, and renders behind basicAuth when enabled (a template render, not a running dashboard).
|
||||
- The service: running and enabled with `NoNewPrivileges`, `MemoryDenyWriteExecute` and `CAP_NET_BIND_SERVICE`, listening on 80 and 443 and redirecting http to https; ufw allows 80 and 443 next to SSH, with the traefik owner tag, in order.
|
||||
- The update path: it updates to another release and back with `traefik_update` (download from local `file://` stand-in releases, checksum check and swap) and asserts the version, an active unit and no leftovers. It leaves the stand-in stub installed, so nothing after it asserts real Traefik behaviour.
|
||||
- The update path: it updates to another release with `traefik_update` (download from local `file://` stand-in releases, checksum check and swap) and asserts the version, an active unit and no leftovers. It leaves the stand-in stub installed, so nothing after it asserts real Traefik behaviour.
|
||||
- The remove path, last: unit and binary are deleted, the service is no longer active, and only the traefik ufw rules are removed.
|
||||
|
||||
The scenario disables the namespace-based sandboxing and the `User=` switch with a drop-in because its container is unprivileged, so that sandboxing is not covered by CI. Certificate issuance is not covered: the Cloudflare credentials are dummies.
|
||||
@@ -96,6 +96,7 @@ The scenario disables the namespace-based sandboxing and the `User=` switch with
|
||||
|
||||
- Idempotent: yes.
|
||||
- Check mode: `--check` is the supported preview; a play-level `check_mode: true` is not supported. On a host without the Traefik binary, the ACME file permissions, the service start and its running check, the `Restart Traefik` handler and the `traefik_update` tasks are skipped under `--check`, because nothing is extracted and the unit file is only simulated.
|
||||
- The role does not refresh an APT cache younger than an hour, so a package from a source you add just before the role (`ansible.builtin.deb822_repository` does not refresh) needs your own cache refresh first.
|
||||
- The role is not a state selector. `main.yml` runs prerequisites and configure unless `traefik_remove` is true; install runs only when the binary is absent; update only when `traefik_update` is true; remove only when `traefik_remove` is true, and then every other task in `main.yml` is skipped.
|
||||
- Download integrity: the archive SHA-256 must appear in the release's checksum file or the play fails.
|
||||
- Secrets: `traefik.env` (mode 0600, root) and `dynamic.yml` are rendered with `no_log: true`, and no backups are kept, so `--diff` never shows them. `dynamic.yml` may hold dashboard htpasswd hashes.
|
||||
|
||||
@@ -1,12 +1,10 @@
|
||||
---
|
||||
# Role variables come from the inventory group_vars in molecule.yml, so the idempotence step
|
||||
# reruns converge with identical configuration; verify's plays override only what they test.
|
||||
# The base ufw play comes first: traefik passes its rules through the mortis.kamino.ufw
|
||||
# service_rules entry point, which needs ufw installed and active. ufw_rules comes from the
|
||||
# same group_vars (the SSH allow rule the lock-out guard requires).
|
||||
# mortis.kamino.ufw runs in prepare.yml, so only traefik counts toward idempotence. Facts are
|
||||
# off: neither the role nor the roles it includes reads any.
|
||||
- name: Converge
|
||||
hosts: all
|
||||
gather_facts: true
|
||||
gather_facts: false
|
||||
roles:
|
||||
- role: mortis.kamino.ufw
|
||||
- role: mortis.kamino.traefik
|
||||
@@ -3,7 +3,7 @@
|
||||
# (MOLECULE_IMAGE) and molecule-ubuntu2604 (MOLECULE_IMAGE_2604) images, pinned in
|
||||
# .gitea/workflows/molecule.yml. Needs outbound network, unlike most scenarios: the role installs
|
||||
# packages with apt and the converge downloads the Traefik release from GitHub (verify's update
|
||||
# path uses file:// stand-ins built by prepare.yml). No privileged mode: systemd needs a writable
|
||||
# path uses a file:// stand-in built by prepare.yml). No privileged mode: systemd needs a writable
|
||||
# cgroup and the firewall tools need NET_ADMIN.
|
||||
driver:
|
||||
name: docker
|
||||
@@ -44,9 +44,10 @@ platforms:
|
||||
- apparmor=unconfined
|
||||
provisioner:
|
||||
name: ansible
|
||||
# One source for every play in converge.yml and verify.yml. The role renders traefik.yml before
|
||||
# its dashboard-auth collision check, so that guard play with other values would change it (and
|
||||
# restart Traefik) before verify's assertions; converge's values must also stay fixed for idempotence.
|
||||
# One source for the prepare plays that read them, converge.yml and verify.yml. The role renders
|
||||
# traefik.yml before its dashboard-auth collision check, so that guard play with other values
|
||||
# would change it (and restart Traefik) before verify's assertions; converge's values must also
|
||||
# stay fixed for idempotence.
|
||||
inventory:
|
||||
group_vars:
|
||||
all:
|
||||
@@ -55,8 +56,8 @@ provisioner:
|
||||
traefik_cloudflare_email: [email protected]
|
||||
traefik_cloudflare_api_token: molecule-not-a-token
|
||||
traefik_domain: example.test
|
||||
# Any release other than the role default: verify's update path goes there and back,
|
||||
# from the stand-ins prepare.yml builds.
|
||||
# Any release other than the role default: verify's update path goes there, from the
|
||||
# stand-in prepare.yml builds.
|
||||
traefik_verify_other_version: v3.7.18
|
||||
ufw_rules:
|
||||
- {rule: allow, port: 22, proto: tcp, comment: ssh}
|
||||
|
||||
@@ -41,26 +41,34 @@
|
||||
ReadWritePaths=
|
||||
User=
|
||||
|
||||
# Stand-in releases for verify's update path, behind file:// URLs: the role's download, checksum
|
||||
# check and swap run unchanged, without fetching two more real releases per host. The converge
|
||||
# traefik passes its rules through the mortis.kamino.ufw service_rules entry point, which needs ufw
|
||||
# installed and active. ufw_rules comes from the inventory group_vars (the SSH allow rule the
|
||||
# lock-out guard requires); the ufw scenario tests that role, so it runs once here, not in converge.
|
||||
- name: Install and enable ufw
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
roles:
|
||||
- role: mortis.kamino.ufw
|
||||
|
||||
# A stand-in release for verify's update path, behind a file:// URL: the role's download, checksum
|
||||
# check and swap run unchanged, without fetching another real release per host. The converge
|
||||
# still downloads the real role default from GitHub.
|
||||
- name: Prepare the stand-in releases
|
||||
- name: Prepare the stand-in release
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
- ../../defaults/main.yml
|
||||
vars:
|
||||
traefik_test_release: "{{ traefik_verify_other_version }}"
|
||||
tasks:
|
||||
- name: Create a directory per stand-in release
|
||||
- name: Create the stand-in release directory
|
||||
ansible.builtin.file:
|
||||
path: "/opt/molecule-download/{{ traefik_test_release }}"
|
||||
state: directory
|
||||
mode: "0755"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
# Answers `version` like Traefik and otherwise stays up like the service.
|
||||
- name: Write the stand-in binaries
|
||||
- name: Write the stand-in binary
|
||||
ansible.builtin.copy:
|
||||
dest: "/opt/molecule-download/{{ traefik_test_release }}/traefik"
|
||||
mode: "0755"
|
||||
@@ -70,25 +78,16 @@
|
||||
version) echo "Version: {{ traefik_test_release | regex_replace('^v', '') }}" ;;
|
||||
*) exec sleep infinity ;;
|
||||
esac
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
- name: Pack the stand-in archives
|
||||
- name: Pack the stand-in archive
|
||||
ansible.builtin.command:
|
||||
argv: [tar, -czf, "{{ traefik_test_archive }}", -C, "/opt/molecule-download/{{ traefik_test_release }}", traefik]
|
||||
creates: "{{ traefik_test_archive }}"
|
||||
vars:
|
||||
traefik_test_archive: "/opt/molecule-download/{{ traefik_test_release }}/traefik_{{ traefik_test_release }}_{{ traefik_os }}_{{ traefik_arch }}.tar.gz"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
|
||||
- name: Write the checksums files in the release format
|
||||
- name: Write the checksums file in the release format
|
||||
ansible.builtin.shell:
|
||||
cmd: sha256sum traefik_*.tar.gz > traefik_{{ traefik_test_release }}_checksums.txt
|
||||
chdir: "/opt/molecule-download/{{ traefik_test_release }}"
|
||||
creates: "traefik_{{ traefik_test_release }}_checksums.txt"
|
||||
loop: ["{{ traefik_verify_other_version }}", "{{ traefik_version }}"]
|
||||
loop_control:
|
||||
loop_var: traefik_test_release
|
||||
@@ -293,11 +293,11 @@
|
||||
traefik_ufw_key_443: "{{ ('allow|443|||||in' | hash('sha1'))[:10] }}"
|
||||
traefik_ufw_tagged: "{{ traefik_ufw_added.stdout_lines | select('match', '^ufw ') | select('search', 'ansible-ufw') | list }}"
|
||||
|
||||
# A version bump through the update path and mortis.kamino._binary_update: down to another
|
||||
# release and back to the role default, both with traefik_update, from prepare.yml's stand-ins.
|
||||
# After the idempotence step, because each run changes the binary, and before the remove path.
|
||||
# A version bump through the update path and mortis.kamino._binary_update: to another release
|
||||
# with traefik_update, from prepare.yml's stand-in. One bump covers the download, checksum check
|
||||
# and swap. After the idempotence step, because it changes the binary, and before the remove path.
|
||||
# It leaves the stand-in stub installed, so nothing after it may assert real Traefik behaviour.
|
||||
- name: Verify the update path with stand-in releases
|
||||
- name: Verify the update path with a stand-in release
|
||||
hosts: all
|
||||
gather_facts: false
|
||||
vars_files:
|
||||
@@ -309,13 +309,10 @@
|
||||
fail_msg: Move traefik_verify_other_version off the role default ({{ traefik_version }}).
|
||||
quiet: true
|
||||
|
||||
- name: Update to the other release, then back to the role default
|
||||
- name: Update to the other release
|
||||
ansible.builtin.include_tasks: tasks/update_and_check.yml
|
||||
loop:
|
||||
- "{{ traefik_verify_other_version }}"
|
||||
- "{{ traefik_version }}"
|
||||
loop_control:
|
||||
loop_var: traefik_verify_target
|
||||
vars:
|
||||
traefik_verify_target: "{{ traefik_verify_other_version }}"
|
||||
|
||||
# The remove path. Last on purpose: it destroys what the plays above verify, and it runs
|
||||
# once, outside the idempotence step (a converge play that changed state would fail that step).
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
- logrotate
|
||||
state: present
|
||||
update_cache: true
|
||||
cache_valid_time: 3600
|
||||
tags: [traefik, prereqs, always]
|
||||
|
||||
- name: Create Traefik group
|
||||
|
||||
Reference in new issue
Block a user