Fix drift check
This commit is contained in:
parent
4bea7cd356
commit
bfe9b5329b
@ -51,10 +51,27 @@
|
||||
delegate_to: localhost
|
||||
register: repo_configs
|
||||
|
||||
- name: Flag extra files on server
|
||||
- name: Build list of Git-managed filenames
|
||||
ansible.builtin.set_fact:
|
||||
git_filenames: "{{ repo_configs.files | map(attribute='path') | map('basename') | list }}"
|
||||
|
||||
- name: Build list of server filenames
|
||||
ansible.builtin.set_fact:
|
||||
server_filenames: "{{ server_configs.files | map(attribute='path') | map('basename') | list }}"
|
||||
|
||||
- name: Find server files that are managed by Git but missing on server
|
||||
ansible.builtin.set_fact:
|
||||
missing_on_server: "{{ git_filenames | difference(server_filenames) }}"
|
||||
|
||||
- name: Flag if any Git-managed file is missing from server
|
||||
ansible.builtin.set_fact:
|
||||
extra_files_on_server: true
|
||||
when: (server_configs.files | length) > (repo_configs.files | length)
|
||||
when: missing_on_server | length > 0
|
||||
|
||||
- name: Show missing files
|
||||
ansible.builtin.debug:
|
||||
msg: "Files in Git but missing on server: {{ missing_on_server }}"
|
||||
when: missing_on_server | length > 0
|
||||
|
||||
- name: Set overall drift flag
|
||||
ansible.builtin.set_fact:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user