Ansible-Playbook

使用模式創建多個目錄並通過ansible循環

  • October 11, 2021

我正在嘗試使用循環並在劇本中要求在具有特定屬性的伺服器上創建多個目錄:模式所有者組。

我想我已經接近了,但沒有得到它的工作。

我收到此錯誤:

(文件)模組不支持的參數:recursive 支持的參數包括:_diff_peek、_original_basename、access_time、access_time_format、attributes、backup、content、delimiter、directory_mode、follow、force、group、mode、modification_time、modification_time_format、owner、path、recurse、regexp ,remote_src,selevel,serole,setype,seuser,src,狀態,unsafe_writes

任何建議將不勝感激:

這是劇本範例:

 - name: ansible create directory with_items example
file:
 path: "{{ item.dest }}"
 mode: "{{item.mode}}"
 owner: "{{item.owner}}"
 group: "{{item.group}}"
 recursive: true   
 state: directory
loop:
 - { dest: '/var/lib/tftpboot/os/uefi/debian11', mode: '0744', owner: 'root', group: 'root' }
 - { dest: '/var/lib/tftpboot/os/uefi/ubuntu2004D', mode: '0744', owner: 'root', group: 'root'}
 - { dest: '/var/lib/tftpboot/os/uefi/f34w', mode: '0744', owner: 'root', group: 'root'}
 - { dest: '/var/lib/tftpboot/os/uefi/f34s', mode: '0744', owner: 'root', group: 'root'}
 - { dest: '/srv/nfs/isos', mode: '0744', owner: 'root', group: 'rpcuser'}
 - { dest: '/srv/nfs/pxe/debian11', mode: '0744', owner: 'root', group: 'rpcuser'}
 - { dest: '/srv/nfs/pxe/ubuntu2004', mode: '0744', owner: 'root', group: 'rpcuser'}
 - { dest: '/srv/nfs/pxe/f34w', mode: '0744', owner: 'root', group: 'rpcuser'}
 - { dest: '/srv/nfs/pxe/f34s', mode: '0744', owner: 'root', group: 'rpcuser'}
 - { dest: '/tmp/debian11', mode: '0744', owner: 'root', group: 'root'}
 - { dest: '/tmp/f34w', mode: '0744', owner: 'root', group: 'root'}
 - { dest: '/tmp/ubuntu2004D', mode: '0744', owner: 'root', group: 'root'}

你的參數有錯別字。參數被呼叫recurse,你已經寫好了recursive

引用自:https://serverfault.com/questions/1080139