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

file module fix attribute issues #83111

Open
wants to merge 3 commits into
base: devel
Choose a base branch
from

Conversation

pinradaThan
Copy link

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
  • Bugfix Pull Request
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.

@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. module This issue/PR relates to a module. has_issue labels Apr 20, 2024
@ansibot

This comment was marked as resolved.

@ansibot ansibot added the needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. label Apr 20, 2024

if prev_state != 'absent':
diff = initial_diff(path, 'absent', prev_state)

if not module.check_mode:
if prev_state == 'directory':
# Check if 'attributes' in file_args
current_attributes = file_args.get('attributes', '')
if '-a' in current_attributes:
Copy link
Member

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

(https://dev.azure.com/ansible/ansible/_build/results?buildId=109805&view=logs&j=c9dc1718-7fc3-5e87-e6a6-571058301006&t=ff7b63cb-2767-53c3-7382-bd37bd9a7b6a&l=2143)

@webknjaz webknjaz added the ci_verified Changes made in this PR are causing tests to fail. label Apr 22, 2024
@mkrizek mkrizek removed the needs_triage Needs a first human triage before being processed. label Apr 23, 2024
@bcoca bcoca changed the title Fixes #79587 file module fix attribute issues Apr 23, 2024
@ansibot ansibot added the stale_ci This PR has been tested by CI more than one week ago. Close and re-open this PR to get it retested. label Apr 30, 2024
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_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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove file or directory with chattr in one task
4 participants