test
This commit is contained in:
parent
db79f854f4
commit
17a6311792
@ -1,37 +0,0 @@
|
||||
# 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
|
||||
@ -85,14 +85,34 @@
|
||||
when: not confd_match
|
||||
|
||||
# Compare content of each file in rsyslog.d (only if filenames match)
|
||||
- name: Compare content of rsyslog.d config files
|
||||
include_tasks:
|
||||
file: check_confd_content.yml
|
||||
- name: Read Git rsyslog.d files content
|
||||
slurp:
|
||||
src: "{{ playbook_dir }}/../../files/rsyslog.d/{{ item }}"
|
||||
delegate_to: localhost
|
||||
register: git_confd_contents
|
||||
loop: "{{ git_confd_names }}"
|
||||
loop_control:
|
||||
loop_var: confd_file
|
||||
when: confd_match
|
||||
|
||||
- name: Read server rsyslog.d files content
|
||||
slurp:
|
||||
src: "{{ rsyslog_config_dir }}/{{ item }}"
|
||||
register: server_confd_contents
|
||||
loop: "{{ git_confd_names }}"
|
||||
when: confd_match
|
||||
|
||||
- name: Compare rsyslog.d file contents and detect drift
|
||||
set_fact:
|
||||
drift_detected: true
|
||||
drifted_files: "{{ drifted_files + ['rsyslog.d/' + item.item] }}"
|
||||
loop: "{{ git_confd_contents.results }}"
|
||||
when:
|
||||
- confd_match
|
||||
- item.content is defined
|
||||
- server_confd_contents.results[ansible_loop.index0].content is defined
|
||||
- (item.content | b64decode | replace('\r\n', '\n')) != (server_confd_contents.results[ansible_loop.index0].content | b64decode | replace('\r\n', '\n'))
|
||||
loop_control:
|
||||
extended: yes
|
||||
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
# Output markers for update-gitops-status.sh parsing
|
||||
# ─────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user