From eaf86b0cc65147dd3fed91764d65718e9ca3ad19 Mon Sep 17 00:00:00 2001 From: Watson Sato Date: Fri, 25 Mar 2022 11:08:35 +0100 Subject: [PATCH] Ansible: When 'file_regex` is set, only operate on files In rule 'file_permissions_library_dirs', when navigating '/lib', the task finds hardlinks and trips on them: "failed: [rhel9] (item={'path': '/lib/locale/en_AG/LC_COLLATE', 'mode': '0644' .... "msg": "src is required for creating new hardlinks"}" This ensure that the Ansible task acts on regular files, and not on the hardlink or symlinks. --- shared/templates/file_groupowner/ansible.template | 1 + shared/templates/file_owner/ansible.template | 1 + shared/templates/file_permissions/ansible.template | 1 + 3 files changed, 3 insertions(+) diff --git a/shared/templates/file_groupowner/ansible.template b/shared/templates/file_groupowner/ansible.template index 8e8bbde440c0..316b89f34f72 100644 --- a/shared/templates/file_groupowner/ansible.template +++ b/shared/templates/file_groupowner/ansible.template @@ -24,6 +24,7 @@ file: path: "{{ item.path }}" group: "{{{ FILEGID }}}" + state: file when: item.gid != {{{ FILEGID }}} with_items: - "{{ files_found.files }}" diff --git a/shared/templates/file_owner/ansible.template b/shared/templates/file_owner/ansible.template index a0d6c51c6139..bf36faca54c7 100644 --- a/shared/templates/file_owner/ansible.template +++ b/shared/templates/file_owner/ansible.template @@ -24,6 +24,7 @@ file: path: "{{ item.path }}" owner: "{{{ FILEUID }}}" + state: file when: item.uid != {{{ FILEUID }}} with_items: - "{{ files_found.files }}" diff --git a/shared/templates/file_permissions/ansible.template b/shared/templates/file_permissions/ansible.template index 4570ace9471d..80753f4fcf4c 100644 --- a/shared/templates/file_permissions/ansible.template +++ b/shared/templates/file_permissions/ansible.template @@ -24,6 +24,7 @@ file: path: "{{ item.path }}" mode: "{{{ FILEMODE }}}" + state: file when: item.mode != '{{{ FILEMODE}}}' with_items: - "{{ files_found.files }}"