rsyslog/ansible/playbooks/check_confd_content.yml
dvirlabs db79f854f4
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
ci/woodpecker/cron/woodpecker Pipeline was successful
test
2026-04-24 16:15:32 +03:00

38 lines
1.2 KiB
YAML

# Helper task to compare individual rsyslog.d config file content
# Called from drift-check.yml with loop_var: confd_file
- name: Read Git version of {{ confd_file }}
slurp:
src: "{{ playbook_dir }}/../../files/rsyslog.d/{{ confd_file }}"
delegate_to: localhost
register: git_file_content
- name: Read server version of {{ confd_file }}
slurp:
src: "{{ rsyslog_config_dir }}/{{ confd_file }}"
register: server_file_content
- name: Normalize and compare {{ confd_file }} content
set_fact:
git_normalized: "{{ git_file_content.content | b64decode | replace('\r\n', '\n') }}"
server_normalized: "{{ server_file_content.content | b64decode | replace('\r\n', '\n') }}"
- name: Check if {{ confd_file }} content matches
set_fact:
file_matches: "{{ git_normalized == server_normalized }}"
- name: Debug {{ confd_file }} comparison
debug:
msg: |
File: {{ confd_file }}
Git size: {{ git_normalized | length }} chars
Server size: {{ server_normalized | length }} chars
Match: {{ file_matches }}
when: not file_matches
- name: Mark drift if {{ confd_file }} differs
set_fact:
drift_detected: true
drifted_files: "{{ drifted_files + ['rsyslog.d/' + confd_file] }}"
when: not file_matches