Я пытаюсь создать и обновить права доступа к каталогу на своем Linux-компьютере, используя нижеприведенную задачу, но она не меняет права собственности должным образом:

например: права доступа к каталогу /home/xyz/xyz/{{ IDM }}и /home/{{ IDM }}праву собственности возвращаются к{{ IDM }}:{{ IDM }}

- name: create directory with loop
  file:
    path: "{{ item.dest }}"
    mode: "{{item.mode}}"
    owner: "{{ IDM }}"
    group: "{{ IDM }}"
    recurse: yes
    state: directory
  loop:
  - { dest: '/home/{{ IDM }}', mode: '0755', owner: root, group: root }
  - { dest: '/home/{{ IDM }}/.ssh', mode: '0700', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/to_xyz', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/to_xyz/known_customers', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/from_xyz', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/from_xyz/merchant_invoice', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/from_xyz/clearing', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/from_xyz/settlement_report', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/archive', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/archive/settlement_report', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/archive/clearing', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/{{ IDM }}/archive/dunning', mode: '0777', owner: "{{ IDM }}", group: "{{ IDM }}" }
  - { dest: '/home/xyz/xyz/{{ IDM }}', mode: '0755', owner: 'root', group: 'root' }
answer

Ну, потому что вы определяете это как {{ IDM }}. Установите ownerи groupк {{ item.owner }}и {{ item.group }}вместо.

- name: create directory with loop
  file:
    path: "{{ item.dest }}"
    mode: "{{ item.mode }}"
    owner: "{{ item.owner }}"
    group: "{{ item.group }}"
    recurse: yes
    state: directory