From a39d1956dd87175879c9e2aa62746b989ddb02d8 Mon Sep 17 00:00:00 2001 From: Remmelt Pit Date: Tue, 18 Nov 2025 23:17:29 +0100 Subject: [PATCH] Make terminfo role idempotent by comparing entries Fixes #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. --- roles/terminfo/tasks/main.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/roles/terminfo/tasks/main.yml b/roles/terminfo/tasks/main.yml index 3a426d8..4c7f31b 100644 --- a/roles/terminfo/tasks/main.yml +++ b/roles/terminfo/tasks/main.yml @@ -12,6 +12,17 @@ changed_when: false check_mode: false +- name: Read remote terminfo entry + ansible.builtin.command: + argv: + - "{{ terminfo_infocmp_cmd }}" + - -x + - "{{ terminfo_term_name }}" + register: terminfo_remote_infocmp_result + changed_when: false + failed_when: false + check_mode: false + - name: Save terminfo entry ansible.builtin.command: argv: @@ -19,4 +30,7 @@ - -x - "-" stdin: "{{ terminfo_infocmp_x_result.stdout }}" + when: > + terminfo_remote_infocmp_result.rc != 0 or + terminfo_infocmp_x_result.stdout != terminfo_remote_infocmp_result.stdout changed_when: true