使用特定 owner/group 创建 link

Create link with specific owner/group

我正在尝试创建一些具有特定 owner/group 的符号链接, 但它总是使用 owner=root 和 group=root 创建的。为什么?

这是我的代码:

- name: Get the directories to create symbolic links
  find:
    paths: /myPath/
  register: result

- name: Creation of symbolic links 
  file:
    src: "{{ item.path }}" 
    dest: /Path_Dest/{{ item.path | basename }}
    owner: 'owner1'
    group: 'group1'
    state: link
  with_items: "{{ result.files }}"   

注:

如果您不指定 follow=False,将遵循符号链接(因为 default is follow=True)并且所有权和组将应用于目标路径。使用:

- name: Creation of symbolic links 
  file:
    src: "{{ item.path }}" 
    dest: /Path_Dest/{{ item.path | basename }}
    owner: 'owner1'
    group: 'group1'
    state: link
    follow: False
  with_items: "{{ result.files }}"