---
- 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}}"
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