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

PermissionError in ansible.builtin.find exits too early #82027

Closed
1 task done
tsia opened this issue Oct 19, 2023 · 1 comment · Fixed by #82282
Closed
1 task done

PermissionError in ansible.builtin.find exits too early #82027

tsia opened this issue Oct 19, 2023 · 1 comment · Fixed by #82282
Assignees
Labels
affects_2.14 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer

Comments

@tsia
Copy link

tsia commented Oct 19, 2023

Summary

when i execute the following find command:
ansible all -m ansible.builtin.find -a "paths=/ patterns='some-file-*.jar' recurse=true"

the result states these warnings:

[WARNING]: Skipped entry '/home/user/thinclient_drives' due to this access issue: [Errno 13] Permission denied: '/home/martensv/thinclient_drives'
[WARNING]: Skipped '/' path due to this access issue: [Errno 13] Permission denied: '/home/user/thinclient_drives'

it is absolutely correct, that ansible can't access the mentioned folder but the second warning causes ansible to stop the find process for the whole / and miss the files we are looking for.

i did some digging and found an ugly work around.

i added

if e.__class__.__name__ == "PermissionError":
    continue

after Line 522 in the except block in modules/find.py but that doesn't seem to be a proper solution

Issue Type

Bug Report

Component Name

find

Ansible Version

$ ansible --version
ansible [core 2.14.5]
  config file = /home/tsiakalt/.ansible.cfg
  configured module search path = ['/home/tsia/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /home/tsia/.local/lib/python3.11/site-packages/ansible
  ansible collection location = /home/tsia/.ansible/collections:/usr/share/ansible/collections
  executable location = /home/tsia/.local/bin/ansible
  python version = 3.11.5 (main, Aug 28 2023, 00:00:00) [GCC 13.2.1 20230728 (Red Hat 13.2.1-1)] (/usr/bin/python3)
  jinja version = 3.1.2
  libyaml = True

Configuration

# if using a version older than ansible-core 2.12 you should omit the '-t all'
$ ansible-config dump --only-changed -t all
ANSIBLE_NOCOWS(/home/tsia/.ansible.cfg) = True
CACHE_PLUGIN(/home/tsia/.ansible.cfg) = memory
CONFIG_FILE() = /home/tsia/.ansible.cfg
DEFAULT_BECOME(/home/tsia/.ansible.cfg) = True
DEFAULT_BECOME_ASK_PASS(/home/tsia/.ansible.cfg) = False
DEFAULT_BECOME_METHOD(/home/tsia/.ansible.cfg) = sudo
DEFAULT_BECOME_USER(/home/tsia/.ansible.cfg) = root
DEFAULT_FORKS(/home/tsia/.ansible.cfg) = 10
DEFAULT_GATHERING(/home/tsia/.ansible.cfg) = smart
DEFAULT_HOST_LIST(/home/tsia/.ansible.cfg) = ['/home/tsia/hosts']
DEFAULT_MANAGED_STR(/home/tsia/.ansible.cfg) = DO NOT EDIT! File is Ansible managed: {file} on {host} by {uid}
DEFAULT_ROLES_PATH(/home/tsia/.ansible.cfg) = ['/home/tsia/roles']
DEFAULT_STDOUT_CALLBACK(/home/tsia/.ansible.cfg) = debug
DEFAULT_TIMEOUT(/home/tsia/.ansible.cfg) = 16
DISPLAY_SKIPPED_HOSTS(/home/tsia/.ansible.cfg) = False
RETRY_FILES_ENABLED(/home/tsia/.ansible.cfg) = False

BECOME:
======

runas:
_____
become_user(/home/tsia/.ansible.cfg) = root

su:
__
become_user(/home/tsia/.ansible.cfg) = root

sudo:
____
become_user(/home/tsia/.ansible.cfg) = root

CALLBACK:
========

default:
_______
display_skipped_hosts(/home/tsia/.ansible.cfg) = False

CONNECTION:
==========

ssh:
___
pipelining(/home/tsia/.ansible.cfg) = True
timeout(/home/tsia/.ansible.cfg) = 16

OS / Environment

Fedora 38

Steps to Reproduce

- name: Find commons-text jar files
          ansible.builtin.find:
            paths: /
            patterns: 'some-file-*.jar'
            recurse: true
            depth: 10
            excludes: '/tmp,/sys,/dev,/proc,/var,/etc,/run,/cdrom,/.snapshots'
          register: find_output

Expected Results

i expected to find all instances of some-file-*.jar

Actual Results

[WARNING]: Skipped entry '/home/user/thinclient_drives' due to this access issue: [Errno 13] Permission denied: '/home/user/thinclient_drives'
[WARNING]: Skipped '/' path due to this access issue: PermissionError[Errno 13] Permission denied: '/home/user/thinclient_drives'
host.example.com | SUCCESS => {
    "ansible_facts": {
        "discovered_interpreter_python": "/usr/libexec/platform-python"
    },
    "changed": false,
    "examined": 130213,
    "files": [],
    "matched": 0,
    "msg": "Not all paths examined, check warnings for details",
    "skipped_paths": {
        "/": "PermissionError[Errno 13] Permission denied: '/home/user/thinclient_drives'",
        "/home/user/thinclient_drives": "[Errno 13] Permission denied: '/home/user/thinclient_drives'"
    }
}

Code of Conduct

  • I agree to follow the Ansible Code of Conduct
@ansibot ansibot added bug This issue/PR relates to a bug. needs_triage Needs a first human triage before being processed. affects_2.14 module This issue/PR relates to a module. labels Oct 19, 2023
@ansibot
Copy link
Contributor

ansibot commented Oct 19, 2023

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the component bot command.

@mattclay mattclay added P3 Priority 3 - Approved, No Time Limitation needs_verified This issue needs to be verified/reproduced by maintainer and removed needs_triage Needs a first human triage before being processed. labels Oct 19, 2023
Akasurde added a commit to Akasurde/ansible that referenced this issue Nov 24, 2023
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@ansibot ansibot added the has_pr This issue has an associated PR. label Nov 24, 2023
@Akasurde Akasurde added verified This issue has been verified/reproduced by maintainer and removed needs_verified This issue needs to be verified/reproduced by maintainer labels Nov 24, 2023
Akasurde added a commit to Akasurde/ansible that referenced this issue Dec 1, 2023
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Jan 8, 2024
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit to Akasurde/ansible that referenced this issue Jan 23, 2024
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Akasurde added a commit that referenced this issue Jan 23, 2024
* Log and skip permission errors on files and directories

Fixes: #82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
@Akasurde Akasurde self-assigned this Jan 23, 2024
@ansible ansible locked and limited conversation to collaborators Feb 6, 2024
Akasurde added a commit to Akasurde/ansible that referenced this issue Mar 21, 2024
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit f73d72e)
Akasurde added a commit to Akasurde/ansible that referenced this issue Mar 21, 2024
* Log and skip permission errors on files and directories

Fixes: ansible#82027

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
(cherry picked from commit f73d72e)
Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
sivel pushed a commit that referenced this issue Apr 10, 2024
* Log and skip permission errors on files and directories

Fixes: #82027


(cherry picked from commit f73d72e)

Signed-off-by: Abhijeet Kasurde <akasurde@redhat.com>
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
affects_2.14 bug This issue/PR relates to a bug. has_pr This issue has an associated PR. module This issue/PR relates to a module. P3 Priority 3 - Approved, No Time Limitation verified This issue has been verified/reproduced by maintainer
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants