Hi Deborah,

use with_items:

- name: Creating multiple tomcat instance
  file: dest=/var/lib/tomcat-instance{{ item }}  state=directory
  with_items:
    - 1
    - 2
    - 3

Or, maybe better way with_sequence:
- name: Creating multiple tomcat instance
  file: dest=/var/lib/tomcat-instance{{ item }}  state=directory
  with_sequence: start=1 end=3

More about loops: http://docs.ansible.com/ansible/playbooks_loops.html


David Karban
Linux server specialist/Specialista na správu linuxových serverů
www.karban.eu

2015-10-01 17:05 GMT+02:00 DEBORAH AKUOKO <[email protected]>:

> I am trying to create multiple directories with different names e.g
> tomacat-1, tomcat-2 etc..
> But i want to do this in the form of a loop. Kindly help me with the yaml
> syntax.
>
> this is what i tried
>
> - name: Creating multiple tomcat instance
>   file: dest=/var/lib/tomcat-instance{1..3}  state=directory
>
> But instead of creating three directories, it creates only one with name "
> tomcat-instance{1..3}"
> Also i would like each of these folders to have a unique port id and
> shutdown port  e.g     -p  8000  -c 8006
>
> --
> 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 post to this group, send email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/c56b427d-167c-4853-91dd-1bbbb1a5cc48%40googlegroups.com
> <https://groups.google.com/d/msgid/ansible-project/c56b427d-167c-4853-91dd-1bbbb1a5cc48%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAOBFM95Z-84v%3Dz4zLRgCS2N9iuPW%2B2%3Dt8LXkotGuWazuTJ-2ig%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to