Ansible
目錄所有者權限未通過 ansible 循環正確更新
我正在嘗試使用以下 ansible 任務在我的 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' }
好吧,因為您將其定義為
{{ 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