Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow disable for calculating size for win_stat #384

Closed
stonesbg opened this issue Jul 4, 2022 · 1 comment · Fixed by #385
Closed

Allow disable for calculating size for win_stat #384

stonesbg opened this issue Jul 4, 2022 · 1 comment · Fixed by #385

Comments

@stonesbg
Copy link

stonesbg commented Jul 4, 2022

SUMMARY

Allow for an opt out flag to be passed as part of win_stat to disable the calculation of size this can be used for both directory and for file.

ISSUE TYPE
  • Feature Idea
COMPONENT NAME

win_stat

ADDITIONAL INFORMATION

Right now, win_stat by default includes the size of a directory. This is fine in most cases but when trying to check for an existence of a drive letter or for a folder with a lot of data in it win_stat will just hang as it tries to calculate this information.

https://github.com/ansible-collections/ansible.windows/blob/main/plugins/modules/win_stat.ps1#L130-L149

It would be nice if there was an opt out option where you could set a flag to ignore directory size calculation. This could be as simple as passing a get_size bool operator to disable the calculation of size. Default could be yes/true as to not break backwards compatibility.

- name: Obtain information about a directory
  ansible.windows.win_stat:
    path: C:\
    get_size: no
  register: file_info

Feature request came about from the scenario where I was checking the existence of a directory. This directory is ephemeral drive so on reboot this drive would get deleted and re-added as part of AWS or GCP. Once created the drive is created the SQL Server tempdb get created on it at 5GB per file. This could be between 4 and 8 files. On initial run this would work first time but on subsequent run the win_stat would hang for hours.

The second instance was when checking the existing of docker folder exists. This data directory was getting moved between c:\ to d:\ and the test was validating that the drive was created in the new location. On initial runs this was fun as now containers had yet been pulled down but as time went on more and more windows container layers were pulled and stored. This directory ending up growing to excess of 30GB and win_stat would hang.

I locally tested by removing the size calculating and that fixed the problem so right now workaround is to not use win_stat and do it with PowerShell for any folders that potentially will grow in the future.

@jborean93
Copy link
Collaborator

Thanks for the suggestion, the PR #385 implements this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants