Exclude localhost from Ansible facts freshness check#2409
Open
berendt wants to merge 1 commit into
Open
Conversation
Cached facts for localhost (and 127.0.0.1/::1) are a byproduct of locally executed or delegated plays, not regular inventory hosts. They are never refreshed by 'osism sync facts', which only targets inventory hosts, so they age past FACTS_MAX_AGE and trigger a stale warning that the suggested remedy can never clear. Skip these hosts in check_ansible_facts() so the freshness check no longer emits permanent, unactionable warnings for them. Closes #2267 Assisted-by: Claude:claude-opus-4-8[1m] Signed-off-by: Christian Berendt <berendt@osism.tech>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
osism apply <role>warns about stale Ansible facts forlocalhost:The suggested remedy
osism sync factsnever clears it.Root cause
check_ansible_facts()scans allansible_facts*keys in Redis, includingansible_factslocalhost. That cache entry is a byproduct of locally executed or delegated plays —localhostis not a regular inventory host. The refresh path (osism sync factsand the periodicgather_factstask) only targets inventory hosts, so thelocalhostentry is never refreshed, ages pastFACTS_MAX_AGE(12h default), and produces a permanent, unactionable warning.Fix
Skip
localhost,127.0.0.1, and::1incheck_ansible_facts(). The freshness check for real inventory hosts is unchanged.Tests
test_check_ansible_facts_local_hosts_never_stale(parametrized overlocalhost/127.0.0.1/::1): far-overaged local facts produce no warning.test_check_ansible_facts_local_host_skipped_real_host_still_stale: a real inventory host is still reported;localhostis excluded.Closes #2267