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

Any option to exclude some files from delete in windows using ansible #90

Closed
Akasurde opened this issue Aug 11, 2020 · 2 comments
Closed

Comments

@Akasurde
Copy link
Member

From @dhikrahashim on Aug 11, 2020 04:06

SUMMARY
ISSUE TYPE

I want to exclude some files from deleting in windows using win_file module.
Unfortunately exclude option is there only for Linux module file, I believe.

I am getting updated application code from developer. I need to keep some files without any change in the windows application like "web.config". In that case I only need to exclude one or two files and I can replace all other files.

Other option I have is, I need to copy original "web.config" in my src folder and idempotent will work.

COMPONENT NAME
ANSIBLE VERSION
Latest
CONFIGURATION
- win_find:
paths: "c:/Users/xxxx/Desktop/Newfolder/test/"
file_type: file
excludes:
 - "Global.asax"
register: found_files

- win_file:
path: "{{ item.path }}"
state: absent
with_items: "{{ found_files.files }}"
================================

- win_find:
paths: "c:/Users/farmoh/Desktop/Newfolder/test-farooq/"
file_type: file
register: found_files

- win_file:
path: "{{ item.path }}"
state: absent
with_items: "{{ found_files.files }}"
when: 'Global.asax not in item.path'

OS / ENVIRONMENT

Windows

ADDITIONAL INFORMATION

Tried all two types plays, nothing works

Copied from original issue: ansible/ansible#71196

@jborean93
Copy link
Collaborator

Unfortunately this isn't possible and not something I think we are interested in looking at adding. Ultimately you will have to provide your own delete logic and use a win_shell or win_powershell task to implement it.

@OneCyrus
Copy link

@jborean93 was there any specific reason why this feature gap should exists between windows and linux? or would you be open for a PR?

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

No branches or pull requests

3 participants