简体   繁体   中英

Ansible subelements (version 2.3)

How to get such a structure? My code doesn't work

user:
  - username: test1
    home: /home/test1
    outbox: Outbox
    inbox: Inbox
    subfolders:
      - _test1
      - _test2
      - _test3

test1
-------test1_test1
----------- Inbox
----------- Outbox
-------test1_test2
----------- Inbox
----------- Outbox
-------test1_test3
----------- Inbox
----------- Outbox

- name: Creating sub-folders
  file: 
    path: "{{ item.0.home }}/{{ item.0.username }}{{ item.0.subfolders }}/{{ item.0.inbox }}"
    mode: 0775
    owner: "{{ item.0.username }}"
    group: "{{ web_user }}"
    state: directory
  with_subelements:
    - "{{ user }}"
    - subfolders
  when: subfolders is defined

Maybe someone will come in handy :)

  file: 
    path: "{{ item.0.home }}/{{ item.0.username }}{{ item.1 }}/{{ item.0.inbox }}"
    mode: 0775
    owner: "{{ item.0.username }}"
    group: "{{ web_user }}"
    state: directory
  with_subelements:
    - "{{ user }}"
    - subfolders

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM