-
Notifications
You must be signed in to change notification settings - Fork 24.1k
file module fix attribute issues #83111
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
Open
pinradaThan
wants to merge
3
commits into
ansible:devel
Choose a base branch
from
pinradaThan:file-changes
base: devel
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
+19
−0
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
…ent to ensure_absent
This comment was marked as resolved.
This comment was marked as resolved.
webknjaz
reviewed
Apr 22, 2024
| if prev_state == 'directory': | ||
| # Check if 'attributes' in file_args | ||
| current_attributes = file_args.get('attributes', '') | ||
| if '-a' in current_attributes: |
Member
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like there's a case when current_attributes is None:
Traceback (most recent call last):
File "<stdin>", line 133, in <module>
File "<stdin>", line 125, in _ansiballz_main
File "<stdin>", line 73, in invoke_module
File "/usr/local/lib/python3.9/runpy.py", line 225, in run_module
return _run_module_code(code, init_globals, run_name, mod_spec)
File "/usr/local/lib/python3.9/runpy.py", line 97, in _run_module_code
_run_code(code, mod_globals, init_globals,
File "/usr/local/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/tmp/ansible_file_payload_unz_zxje/ansible_file_payload.zip/ansible/modules/file.py", line 1007, in <module>
File "/tmp/ansible_file_payload_unz_zxje/ansible_file_payload.zip/ansible/modules/file.py", line 1001, in main
File "/tmp/ansible_file_payload_unz_zxje/ansible_file_payload.zip/ansible/modules/file.py", line 540, in ensure_absent
TypeError: argument of type 'NoneType' is not iterable
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
bug
This issue/PR relates to a bug.
ci_verified
Changes made in this PR are causing tests to fail.
has_issue
module
This issue/PR relates to a module.
needs_rebase
https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html
needs_revision
This PR fails CI tests or a maintainer has requested a review/revision of the PR.
stale_ci
This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested.
stale_pr
This PR has not been pushed to for more than one year.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
SUMMARY
Fixes #79587
This change ensures that directories with the +a (append-only) attribute can be removed by first clearing the attribute before attempting deletion. Previously, directories with the +a attribute could not be deleted when specified -a in the same task, causing errors in playbooks where directory removal was expected. This is inconsistent as we are able to specify +a in the same task as directory creation.
ISSUE TYPE
ADDITIONAL INFORMATION
The modification introduces checks and procedures to manage file attributes effectively, especially focusing on the append-only attribute to ensure that there are no other unwanted behavior.
Steps to Reproduce:
Create a directory and set the +a attribute.
Try to remove the directory without changing attributes (Expected to fail).
Remove the +a attribute.
Successfully delete the directory.