Not really clear why command or shell doesn’t meet your needs but take a look 
at find, file or stat perhaps. See full list of modules below:

https://docs.ansible.com/ansible/latest/modules/list_of_all_modules.html

Regards
Phil

From: [email protected] <[email protected]> On 
Behalf Of [email protected]
Sent: 19 July 2019 10:40
To: Ansible Project <[email protected]>
Subject: [ansible-project] Is there any Alternative of command/shell module

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]<mailto:[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<https://groups.google.com/d/msgid/ansible-project/cd9ca004-a446-4900-9fe1-180cd76a22eb%40googlegroups.com?utm_medium=email&utm_source=footer>.

-- 
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/4670a6b25881475da73efad653593f5c%40bham.ac.uk.

Reply via email to