Skip to content

Commit d289282

Browse files
spetrosiclaude
authored andcommitted
fix: Update sr_fingerprint task calls to use new structured parameters
The sr_fingerprint module was rewritten to accept structured parameters (status, role_name, role_path, etc.) instead of a free-form sr_message. Update the role tasks and tests to match the new module interface. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent b20f472 commit d289282

4 files changed

Lines changed: 51 additions & 13 deletions

File tree

tasks/main.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,10 @@
8585

8686
- name: Record role success fingerprint
8787
sr_fingerprint:
88-
sr_message: >-
89-
success system_role:ssh ansible_version={{ ansible_version.full }}
90-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
88+
status: success
89+
role_name: ssh
90+
role_path: "{{ role_path }}"
91+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
92+
distribution: "{{ ansible_facts['distribution'] }}"
93+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
94+
write_log_file: "{{ __ssh_write_log_file }}"

tasks/set_vars.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,13 @@
77

88
- name: Record role begin fingerprint
99
sr_fingerprint:
10-
sr_message: >-
11-
begin system_role:ssh ansible_version={{ ansible_version.full }}
12-
{{ ansible_facts['distribution'] }}-{{ ansible_facts['distribution_version'] }}
10+
status: begin
11+
role_name: ssh
12+
role_path: "{{ role_path }}"
13+
ansible_play_hosts_all: "{{ ansible_play_hosts_all }}"
14+
distribution: "{{ ansible_facts['distribution'] }}"
15+
distribution_version: "{{ ansible_facts['distribution_version'] }}"
16+
write_log_file: "{{ __ssh_write_log_file }}"
1317

1418
- name: Determine if system is ostree and set flag
1519
when: not __ssh_is_ostree is defined

tests/tests_default.yml

Lines changed: 35 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,51 @@
2525
- name: Run role
2626
include_tasks: tasks/run_role_with_clear_facts.yml
2727
vars:
28+
__ssh_write_log_file: true
2829
__sr_public: true
2930

30-
# look for the exact module invocation, not some other message that might contain the string
31-
- name: Check system journal contains role fingerprints
31+
- name: Get fingerprint entries from journal
3232
ansible.builtin.shell:
3333
executable: /bin/bash
3434
cmd: >-
3535
set -eo pipefail;
3636
journalctl --since "{{ __journal_start_time }}" --no-pager |
37-
grep -v " Invoked with" | grep "sr_fingerprint.*begin system_role:ssh" ||
38-
{ echo ERROR: BEGIN fingerprint not found; exit 1; };
39-
journalctl --since "{{ __journal_start_time }}" --no-pager |
40-
grep -v " Invoked with" | grep "sr_fingerprint.*success system_role:ssh" ||
41-
{ echo ERROR: SUCCESS fingerprint not found; exit 1; }
37+
grep -v " Invoked with" |
38+
grep "sr_fingerprint.*role_name=ssh"
39+
register: __register_journal_fingerprints
4240
changed_when: false
4341
when: __register_dev_log.stat.exists
4442

43+
- name: Check that the log file was written
44+
ansible.builtin.slurp:
45+
path: /var/log/sysroles.jsonl
46+
register: __register_log_file
47+
48+
- name: Verify log file and journal fingerprints
49+
when: __register_dev_log.stat.exists
50+
vars:
51+
__journal_lines: "{{ __register_journal_fingerprints.stdout_lines }}"
52+
__journal_begin: "{{ __journal_lines | select('search', 'status=begin') | list }}"
53+
__journal_success: "{{ __journal_lines | select('search', 'status=success') | list }}"
54+
__begin_date: "{{ (__journal_begin[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
55+
__success_date: "{{ (__journal_success[0] | regex_search('date=([^ ]+)', '\\1'))[0] }}"
56+
__file_content: "{{ __register_log_file.content | b64decode }}"
57+
block:
58+
- name: Print contents of logs
59+
debug:
60+
var: item
61+
loop:
62+
- "{{ __file_content }}"
63+
- "{{ __journal_lines }}"
64+
65+
- name: Assert content is correct
66+
ansible.builtin.assert:
67+
that:
68+
- __journal_begin | length > 0
69+
- __journal_success | length > 0
70+
- __begin_date in __file_content
71+
- __success_date in __file_content
72+
4573
- name: Restore configuration files
4674
hosts: all
4775
vars:

vars/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ __ssh_required_facts:
2626
__ssh_required_facts_subsets: "{{ ['!all', '!min'] +
2727
__ssh_required_facts }}"
2828

29+
__ssh_write_log_file: false
30+
2931
# BEGIN - DO NOT EDIT THIS BLOCK - rh distros variables
3032
# Ansible distribution identifiers that the role treats like RHEL
3133
__ssh_rh_distros:

0 commit comments

Comments
 (0)