fix(ansible): Run now runs the playbook and leaves the schedule's time alone (#5445)
CI / lint (push) Successful in 2s
CI / unit (push) Successful in 1m51s
CI / integration (push) Successful in 1m45s
CI / publish (push) Successful in 2m21s

Run now set last_run_at to the click, and a schedule's next turn counts
from last_run_at, so a manual run of the nightly prune at 14:00 moved
every later run to 14:00. Operator ruling: "run now shouldn't change the
schedule it should just run the playbook and leave the schedule as it
was."

Run now no longer touches last_run_at. It still records the run as
last_run_id, so the list shows it and a firing during it is skipped.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 22:08:18 -04:00
co-authored by Claude Opus 5.5
parent 401bfb5251
commit 4a33046aef
2 changed files with 72 additions and 2 deletions
+6 -2
View File
@@ -743,12 +743,16 @@ async def run_schedule_now(schedule_id: str):
inventory_scope=inventory_scope, params=params,
triggered_by=session["user_id"], origin="schedule", origin_id=schedule_id,
)
# Run now runs the playbook and leaves the schedule where it was: its
# time of day (last_run_at, the slot its next turn counts from) is not
# touched (operator, 2026-10-09). The run is still the schedule's latest,
# so the list shows it and a firing while it goes is skipped (#5158).
async with current_app.db_sessionmaker() as db:
async with db.begin():
fresh = await db.get(AnsibleSchedule, schedule_id)
if fresh:
fresh.last_run_at = datetime.now(timezone.utc)
fresh.last_run_id = run.id if run else None
if run:
fresh.last_run_id = run.id
fresh.last_error = err
await _audit("ansible.schedule.run_now", "ansible_schedule", schedule_id,
{"playbook": playbook_path, "run_id": run.id if run else None, "error": err})