Hi you've missed a few basic things. The vars file contains a duplicate variable layers - that won't work. Also, you appear to want to loop over the variable layers, but you don't actually use it. Have a look at this URL, it has some nice examples of how loops work:
https://docs.ansible.com/ansible/latest/user_guide/playbooks_loops.html#iterating-over-a-simple-list On Mon, 16 Mar 2020 at 08:21, Shifa Shaikh <[email protected]> wrote: > > Here is my variable file: > > cat vars.yml > --- > > layers: > - name: APP > layers: > - name: WLS > > > Here is my playbook > > cat varloop.yml > --- > > hosts: localhost > vars_files: > - vars.yml > > > > tasks: > - name: Create sublinks based of bad.txt files > include_tasks: "{{ playbook_dir }}/inner.yml" > loop: "{{ layers }}" > loop_control: > loop_var: my_result > > inner.yml > - name: Generate JSON data > block: > - file: path="{{ playbook_dir }}/dashboard/{{ my_result.name }} > state=directory recurse=yes" > > > However, I'm getting the following error running the code: > > TASK [file] > ************************************************************************************************************************************************* > fatal: [localhost]: FAILED! => {"changed": false, "msg": "file > (/tmp/dashboard/APP state=directory recurse=yes) is absent, cannot continue", > "path": "/tmp/dashboard/APP state=directory recurse=yes"} > > I was expecting the play to create the directory "/tmp/dashboard/APP", > however it errors and fails. Can you please suggest ? > > -- > You received this message because you are subscribed to the Google Groups > "Ansible Project" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/ansible-project/0fe8246b-1d71-44c4-baa0-6185815366a1%40googlegroups.com. -- Dick Visser Trust & Identity Service Operations Manager GÉANT -- You received this message because you are subscribed to the Google Groups "Ansible Project" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/CAL8fbwPqEBHn2E2kU3WDYdOH7sUDoh6yimBY%3DDKrWV11yBQRXQ%40mail.gmail.com.
