Problem running Varibles in loop

Hi ,

I’m trying to create folders in loop under HDFS file system - From some reason, I can not run it in loop

The playbook needs to run 2 commands

  1. hadoop fs -mkdir folder1
  2. hadoop fs -mkdir folder2

Try #1 -

- hosts: gw
  become: true
  become_user: hdfs
  vars:
    folders:
        - /folder1
        - /folder2

  tasks:

Hi ,

I'm trying to create folders in loop under HDFS file system - From some reason, I can not run it in loop

The playbook needs to run 2 commands
1. hadoop fs -mkdir folder1
2. hadoop fs -mkdir folder2

*Try #1 - *

- hosts: gw
  become: true
  become_user: hdfs
  vars:
    folders:
        - /folder1
        - /folder2

  tasks:

   - name: create Main HDFS folders
     shell: hadoop fs -mkdir {{ folders }}
     with_items: folders

I would say you could derive it from the docs, but this should work:

- name: create Main HDFS folders
  shell: "hadoop fs -mkdir {{ item }}"
  with_items: "{{ folders }}"

Regards
        Racke