obtain information about a file in windows using ansible playbook

0 votes
How do I obtain information about a file in windows using ansible playbook?
Jun 10, 2019 in Ansible by Travis
267 views

1 answer to this question.

0 votes

Hey @Travis, you can use the win_stat module of ansible for this purpose. This module helps you fetch information about a file or folder. Have a look at the Docs for more details on parameters and return values. One of the example to write a task for obtaining information about a file in windows would be something like this:

- name: Obtain information about a file in windows
  win_stat:
    path: path to the file
  register: file info

In path you add the path of the file whose information you're trying to obtain and in the register section, you add the information that you'd like to register or save or kept noted.

answered Jun 10, 2019 by Drake
What if I want to get folder information?
Hi Emily, you use the same task but just replace the path from the path to file to path to the folder and you're good to go.

Related Questions In Ansible

0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
950 views
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,850 points
1,311 views
0 votes
1 answer

ansible playbook: using multiple variables in loops

Use an indexed hostname, and then define ...READ MORE

answered Jul 16, 2018 in Ansible by DareDev
• 6,850 points
7,436 views
+1 vote
1 answer

Is it possible to append a large amount of text to a file using Ansible?

Here is concept which you can follow. blockinfile is ...READ MORE

answered Jul 30, 2018 in Ansible by Atul
• 10,250 points
4,276 views
+13 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 26, 2018 in DevOps & Agile by DragonLord999
• 8,400 points
412 views
0 votes
1 answer
0 votes
1 answer

Get MD5 checksum of a windows file using Ansible

Hi @Travis, you can use the win_stat ...READ MORE

answered Jun 10, 2019 in Ansible by Greg
442 views
+1 vote
1 answer