Score:0

Create multiple directories with mode and loop via ansible

cn flag

I'm trying to play with loop and ask in a playbook to ansible creating multiple directories on a server with specific attributes : mode owner group .

I think i'm close but don't get it working.

I get this error:

Unsupported parameters for (file) module: recursive Supported parameters include: _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

Any advice would be very appreciated :

Here is the playbook sample :

  - 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'}
Score:2
in flag

You have a typo in the parameters. The parameter is called recurse, you've written recursive.

proxyd43 avatar
cn flag
Thank you. I really need some rest.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.