Make terminfo role idempotent - #2
Open
remmelt wants to merge 1 commit into
Open
Conversation
Fixes moreati#1 The role previously always reported "changed" on every run due to hardcoded `changed_when: true`. This change makes the role idempotent by: 1. Reading the remote terminfo entry (if it exists) 2. Comparing local vs remote entries 3. Only running `tic` when they differ or remote entry doesn't exist The `tic` command now only runs when: - The remote terminfo entry doesn't exist (rc != 0), OR - The local and remote entries differ This eliminates noise in playbook output and makes it easier to identify actual configuration changes.
Author
|
Looks good? |
moreati
requested changes
Dec 7, 2025
| - "{{ terminfo_term_name }}" | ||
| register: terminfo_remote_infocmp_result | ||
| changed_when: false | ||
| failed_when: false |
Owner
There was a problem hiding this comment.
I'm not keen on this. What if infocmp isn't found? Or some file permission error occurs?
Owner
Sorry, TIL only I could see the comment I left a few weeks ago |
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.
Fixes #1
Summary
The
terminforole previously always reported "changed" on every playbook run due to hardcodedchanged_when: true. This PR makes the role idempotent by comparing the local and remote terminfo entries before runningtic.Changes
infocmp -xto read the existing terminfo entry from the target systemfailed_when: falseso the task succeeds even when the terminfo entry doesn't exist yetticcommand now only runs when:rc != 0), ORBenefits
Testing
The logic has been implemented to:
ticwhen the terminfo entry is already up to dateticwhen the entry is missing or differs from the local version