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 in Ansible by Travis
67 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 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
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,810 points
627 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,810 points
4,822 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,240 points
2,758 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,380 points
180 views
0 votes
1 answer
0 votes
1 answer
+1 vote
1 answer