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

Add mindepth, maxdepth parameters to find module #36389

Closed

Conversation

giovannisciortino
Copy link
Contributor

@giovannisciortino giovannisciortino commented Feb 19, 2018

SUMMARY

Fixes #36369
This PR adds the "mindepth" and "maxdepth" parameters to the module find in the source code and in ansible-doc module page.
This parameter are based on the homonym features present in GNU find command.

Furthermore a new test for mindepth maxdepth parameters has been added in test/integration/targets/find/tasks/main.yml file

ISSUE TYPE
  • Feature Pull Request
COMPONENT NAME

find.py

ANSIBLE VERSION
$ ./bin/ansible --version
ansible 2.6.0 (pull-issue-36369 6b965ce1e2) last updated 2018/02/19 15:41:02 (GMT +200)
  config file = /etc/ansible/ansible.cfg
  configured module search path = [u'/home/gsciorti/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python module location = /home/gsciorti/PycharmProjects/ansible/lib/ansible
  executable location = ./bin/ansible
  python version = 2.7.14 (default, Dec 11 2017, 14:52:53) [GCC 7.2.1 20170915 (Red Hat 7.2.1-2)]
ADDITIONAL INFORMATION

Before this pull request mindepth and maxdepth parameters wasn't implemented

Prepare the a directory/file structure to test the PR:

[g@g ansible]$ mkdir -p /tmp/test_find/a/b/c/d
[g@g ansible]$ mkdir -p /tmp/test_find/e/f/g/h
[g@g ansible]$ touch /tmp/test_find/a/1.txt /tmp/test_find/a/b/2.jpg /tmp/test_find/a/b/c/d/4.xml /tmp/test_find/e/5.json /tmp/test_find/e/f/6.swp /tmp/test_find/e/f/g/7.img /tmp/test_find/e/f/g/h/8.ogg

Example 1: module find with mindepth parameter

[g@g ansible]$ ./bin/ansible localhost -m module -m find -a "paths=/tmp/test_find recurse=True mindepth=3" | grep path
...
            "path": "/tmp/test_find/e/f/6.swp", 
...
            "path": "/tmp/test_find/e/f/g/7.img", 
...
            "path": "/tmp/test_find/e/f/g/h/8.ogg", 
...
            "path": "/tmp/test_find/a/b/2.jpg", 
...
            "path": "/tmp/test_find/a/b/c/d/4.xml", 
...

Example 2: module find with maxdepth parameter

[gsciorti@gsciorti ansible]$ ./bin/ansible localhost -m module -m find -a "paths=/tmp/test_find recurse=True maxdepth=4" | grep path
...
            "path": "/tmp/test_find/e/5.json", 
...
            "path": "/tmp/test_find/e/f/6.swp", 
...
            "path": "/tmp/test_find/e/f/g/7.img", 
...
            "path": "/tmp/test_find/a/1.txt", 
...
            "path": "/tmp/test_find/a/b/2.jpg", 
...

Example 3: module find with mindepth and maxdepth parameters

[g@g ansible]$ ./bin/ansible localhost -m module -m find -a "paths=/tmp/test_find recurse=True mindepth=2 maxdepth=3" |grep path
...
            "path": "/tmp/test_find/e/5.json", 
...
            "path": "/tmp/test_find/e/f/6.swp", 
...
            "path": "/tmp/test_find/a/1.txt", 
...
            "path": "/tmp/test_find/a/b/2.jpg", 
...

Example 3: module find with mindepth and maxdepth parameters with different values

[g@g ansible]$ ./bin/ansible localhost -m module -m find -a "paths=/tmp/test_find recurse=True mindepth=4 maxdepth=5" |grep path
...
            "path": "/tmp/test_find/e/f/g/7.img", 
...
            "path": "/tmp/test_find/e/f/g/h/8.ogg", 
...
            "path": "/tmp/test_find/a/b/c/d/4.xml", 
...



@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. feature_pull_request module This issue/PR relates to a module. needs_triage Needs a first human triage before being processed. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests. labels Feb 19, 2018
@ansibot
Copy link
Contributor

ansibot commented Feb 19, 2018

The test ansible-test sanity --test validate-modules [explain] failed with 2 errors:

lib/ansible/modules/files/find.py:0:0: E309 version_added for new option (maxdepth) should be 2.6. Currently 2.5
lib/ansible/modules/files/find.py:0:0: E309 version_added for new option (mindepth) should be 2.6. Currently 2.5

click here for bot help

@ansibot ansibot added ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. and removed core_review In order to be merged, this PR must follow the core review workflow. labels Feb 19, 2018
@ansibot ansibot added core_review In order to be merged, this PR must follow the core review workflow. and removed ci_verified Changes made in this PR are causing tests to fail. needs_revision This PR fails CI tests or a maintainer has requested a review/revision of the PR. labels Feb 19, 2018
@ryansb ryansb removed the needs_triage Needs a first human triage before being processed. label Feb 20, 2018
@ansibot ansibot added 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. feature This issue/PR relates to a feature request. and removed core_review In order to be merged, this PR must follow the core review workflow. feature_pull_request labels Feb 28, 2018
@ansible ansible locked and limited conversation to collaborators Apr 27, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature This issue/PR relates to a feature request. 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. support:core This issue/PR relates to code supported by the Ansible Engineering Team. test This PR relates to tests.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mindepth, maxdepth parameters to find module
3 participants