I want to create multiple directories(test1,test2) with 2 sub directories (/home/test1/bin and /home/test2/conf) similarly for test2. My playbook looks like this :
I think that errors raised because you used file
module 2 times in 1 task. You should only use 1 module per task.
In your case, you should use nested loop to create multiple directories and subdirectories.
Example:
---
- hosts: localhost
tasks:
- name: test
file: path=/tmp/{{item.0}}/{{item.1}} state=directory
with_nested:
- ['test1', 'test2']
- ['bin', 'conf']