Swaps a staged, verified binary into place for a systemd service: refuse when nothing executable is staged, then reload, stop and wait, back up the live binary, rename the staged file over it, start and wait for active, and compare the reported version. A failure after the stop restores this run's backup, starts the service again and fails with a message that says whether the restore and the restart worked. Under --check the waits and the version check are skipped, so a preview against a stopped service does not fall into the rollback. The staged file is removed in every case. The role is internal (ADR 0004 in the environment repository): called only by roles of this Collection by FQCN, outside the public API, marked by the underscore, [INTERNAL] in its meta and argument_specs, and a first task that refuses a call without a parent role. traefik is its first caller and arrives in the same release. Two molecule scenarios use stub binaries under a stub unit, without network: default (successful bump and idempotence, a binary that cannot start, a binary that reports the wrong version, nothing staged, a direct call, a first install) and check_mode (the bump under molecule check against a stopped service changes nothing). Lint: role-name is skipped (its regex rejects the leading underscore, as for prometheus.prometheus roles/_common), meta has no role_name (schema[meta] uses the same regex and cannot be skipped), and .ansible-lint-ignore lists the role's own files for var-naming[no-role-prefix], which strips the underscore from the variable but not from the role name and so cannot pass. The ignore file is kept out of the Collection build and is on the scenario picker's IGNORED list. The README Roadmap no longer lists the role. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
32 lines
939 B
YAML
32 lines
939 B
YAML
---
|
|
- name: Verify
|
|
hosts: all
|
|
gather_facts: false
|
|
tasks:
|
|
- name: Read the stub version
|
|
ansible.builtin.command:
|
|
argv: [/usr/local/bin/stubd, version]
|
|
register: check_version
|
|
changed_when: false
|
|
|
|
- name: Stat the staged file and the backup
|
|
ansible.builtin.stat:
|
|
path: "{{ check_path }}"
|
|
loop: [/usr/local/bin/stubd.new, /usr/local/bin/stubd.bak]
|
|
loop_control:
|
|
loop_var: check_path
|
|
register: check_leftovers
|
|
|
|
- name: Read the stub unit
|
|
ansible.builtin.systemd:
|
|
name: stubd
|
|
register: check_unit
|
|
|
|
- name: The preview changed nothing and left the service down
|
|
ansible.builtin.assert:
|
|
that:
|
|
- check_version.stdout == 'stubd version v1.0.0'
|
|
- check_leftovers.results | selectattr('stat.exists') | list | length == 0
|
|
- check_unit.status.ActiveState in ['inactive', 'failed']
|
|
quiet: true
|