It's not clear what you are trying to do. Depending on your use case you could either use fileglob: https://docs.ansible.com/ansible/latest/plugins/lookup/fileglob.html Or if you need to filter on specific permissions etc, use the find module: https://docs.ansible.com/ansible/latest/modules/find_module.html
Dick On Fri, 19 Jul 2019 at 11:40, Rakesh Parida <[email protected]> wrote: > > I prepared a playbook as follows: > --- > - hosts: localhost > vars: > directory_name: /root/raka-tests/ > tasks: > - name: List the Contents of dir > command: ls -lrt {{ directory_name }} > register: files > - debug: > msg: "{{ files.stdout_lines}}" > > o/p: > TASK [debug] > *********************************************************************************************************************************************************** > ok: [localhost] => { > "msg": [ > "total 80", > "-rw-r--r--. 1 root root 945 Jul 12 05:53 rel.yml", > "-rw-r--r--. 1 root root 280 Jul 12 06:19 playbook.yaml", > "-rw-r--r--. 1 root root 237 Jul 12 09:00 rakesh.yml", > "-rw-r--r--. 1 root root 179 Jul 15 05:40 playbook2.yml", > "-rw-r--r--. 1 root root 376 Jul 15 05:49 playbook3.yml", > "-rw-r--r--. 1 root root 376 Jul 15 05:52 playbook4.yml", > > I dont want to use command/shell module. Is there any module which will show > me the list sof contents of adirectory > > -- > 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/cd9ca004-a446-4900-9fe1-180cd76a22eb%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/CAL8fbwOaOrft8Uzr0dqnb_C0o7y8O4yMkwcM8kNwUmztL4A0rQ%40mail.gmail.com.
