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
1,465 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 11, 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
4,155 views
0 votes
1 answer

How to overwrite the content of a file in remote systems using Ansible playbook?

Hi@akhtar, You can find one argument in the ...READ MORE

answered Aug 2, 2020 in Ansible by MD
• 95,460 points
14,404 views
0 votes
1 answer

How to add multiple lines in a file using Ansible playbook?

Hi@akhtar, You can update your file using lineinfile ...READ MORE

answered Sep 16, 2020 in Ansible by MD
• 95,460 points
26,629 views
0 votes
1 answer

How to create a security group in AWS using Ansible-Playbook?

Hi@akhtar, You can use the ec2_group module in ...READ MORE

answered Aug 13, 2020 in Ansible by MD
• 95,460 points
3,824 views
+15 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 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
4,036 views
+2 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 11, 2019 in Ansible by Greg
3,142 views
+1 vote
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP