Check out looping over
subelements
http://docs.ansible.com/playbooks_loops.html#looping-over-subelements
On Wednesday, April 23, 2014 9:55:53 PM UTC+2, Kenton Brede wrote:
>
> Just starting out with Ansible. Currently I've got:
>
> ---
> - hosts: myhost.example.com
> remote_user: user1
> sudo: yes
> tasks:
> - name: remove select files in root
> command: /bin/rm /root/{{ item }}
> with_items:
> - testing
> - testing2
>
>
>
> This works fine but for each directory I have to create a new task.
>
> What I'd like to do is something like:
>
> tasks:
> - name: remove files
> command: /bin/rm {{ dir/files }}
> dirs_files:
> dir: '/root'
> files:
> - testing
> - testing2
> dir: '/home/user'
> files:
> - testfile
> - testfile2
>
> Obviously that's not going to work but hopefully it illustrates what I'd
> like to do. I just don't want to have to write different tasks for
> different directories.
>
> Any help appreciated.
> Thanks,
> Kent
>
>
>
--
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/5699fada-1ab0-480c-8cb3-daad12e080f6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.