On Mon, 18 May 2020 at 20:39, דודו דודו <dudu.confirm@gmail.com> wrote:
Hi, I’m trying to create folder structure on HDFS storage. I have 3 main folders and each has subfolders.
Thank you.
Configuration file:
companies:
- company_folder_name: /ibm
department:
- it
- logistic
- company_folder_name: /hp
department:
- company_folder_name: /dell
department:
- it
Playbook:
## Createing the main folders - working fine ##
- name: create company folders
shell: hadoop fs -mkdir {{ item.company_folder_name }}
register: result
ignore_errors: yes
with_items:
- "{{ companies }}"
## Create subfolders - Not working ##
- name: create department folders
shell: hadoop fs -mkdir {{ item.company_folder_name }}/{{item.department}}
register: result
ignore_errors: yes
with_items:
- "{{ companies }}"
You iterate over "companies" but that contains a list itself, so
items.department won't work.
Why do you want to ignore errors BTW? they're usually a sign that
something is wrong and needs fixing....
The attribute 'department' must be a list, even an empty one 'department:
'. If 'department' isn't a list the plugin 'subelements' will crash. Fix
the dictionary.