win_shell command execution

15 views
Skip to first unread message

Uppara venkat

unread,
Oct 8, 2019, 4:31:48 AM10/8/19
to ansible...@googlegroups.com
Hi all,
I'm trying to list the files with the name of  "PackageDeploy" using as below but getting all other files also in the directory.

- win_shell: 'dir PackageDeploy*.* /b {{directory}}\configurations\jmxterm > {{directory}}\configurations\temp'
      args:
         executable: cmd
      register: list_out


Could you please suggest the right method for list the file with name ?


Best regards,
Venkat

J Hawkesworth

unread,
Oct 8, 2019, 6:08:06 PM10/8/19
to Ansible Project
You would probably need to write like this:

- win_shell: 'dir PackageDeploy*.* /b > {{directory}}\configurations\temp'
   args:
      executable: cmd
      chdir: '{{directory}}\configurations\jmxterm'     
   register: list_out

But its probably much better to use win_find module https://docs.ansible.com/ansible/latest/modules/win_find_module.htmld as the results will be easier to make use of than the contents of your list_out registered variable.

- name: find PackageDeploy files
  win_find:
     paths: '{{directory}}\configurations\jmxterm'
     patterns: 'PackageDeploy*.*'
  register: package_deploy_info

Hope this helps,

Jon

Uppara venkat

unread,
Oct 9, 2019, 6:48:50 AM10/9/19
to ansible...@googlegroups.com
Thanks Jon, it's working now


--
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 ansible-proje...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/2bde5cb5-8089-4085-be75-d57983704fa2%40googlegroups.com.


--






Thanks& Regards,
venkatesulu.U
8147041026
Reply all
Reply to author
Forward
0 new messages