Skip to content

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 == '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
@ansibot ansibot added the needs_rebase https://docs.ansible.com/ansible/devel/dev_guide/developing_rebasing.html label Oct 10, 2024
@ansibot ansibot added the stale_pr This PR has not been pushed to for more than one year. label Apr 22, 2025
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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove file or directory with chattr in one task

4 participants