通过 ansible 创建具有模式和循环的多个目录

通过 ansible 创建具有模式和循环的多个目录

我正在尝试使用循环并在剧本中要求在服务器上创建具有特定属性的多个目录:模式所有者组。

我想我已经接近了,但是还没有让它发挥作用。

我收到此错误:

(文件) 模块不支持的参数: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、state、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'}

答案1

参数中有拼写错误。该参数称为recurse,你写道recursive

相关内容