From ce48751033fecfc942837b6c4a6f430f037ee8e5 Mon Sep 17 00:00:00 2001 From: Abhijeet Kasurde Date: Tue, 4 Aug 2020 18:30:41 +0530 Subject: [PATCH] filetree: Update example and documentation for plugin (#728) Fixes: #727 Signed-off-by: Abhijeet Kasurde --- plugins/lookup/dig.py | 2 +- plugins/lookup/filetree.py | 42 +++++++++++++++++++++----------------- 2 files changed, 24 insertions(+), 20 deletions(-) diff --git a/plugins/lookup/dig.py b/plugins/lookup/dig.py index 8f39330522..3f086de97e 100644 --- a/plugins/lookup/dig.py +++ b/plugins/lookup/dig.py @@ -68,7 +68,7 @@ EXAMPLES = """ RETURN = """ _list: description: - - list of composed strings or dictonaries with key and value + - list of composed strings or dictionaries with key and value If a dictionary, fields shows the keys returned depending on query type contains: ALL: diff --git a/plugins/lookup/filetree.py b/plugins/lookup/filetree.py index 9fbb8aa230..f5653baa1f 100644 --- a/plugins/lookup/filetree.py +++ b/plugins/lookup/filetree.py @@ -4,7 +4,7 @@ from __future__ import (absolute_import, division, print_function) __metaclass__ = type -DOCUMENTATION = ''' +DOCUMENTATION = r''' lookup: filetree author: Dag Wieers (@dagwieers) short_description: recursively match all files in a directory tree @@ -19,7 +19,7 @@ options: required: True ''' -EXAMPLES = """ +EXAMPLES = r""" - name: Create directories ansible.builtin.file: path: /web/{{ item.path }} @@ -45,46 +45,50 @@ EXAMPLES = """ mode: '{{ item.mode }}' with_filetree: web/ when: item.state == 'link' + +- name: list all files under web/ + ansible.builtin.debug: + msg: "{{ lookup('community.general.filetree', 'web/') }}" """ -RETURN = """ +RETURN = r""" _raw: description: list of dictionaries with file information contains: src: description: - - full path to file - - not returned when C(item.state) is set to C(directory) + - full path to file. + - not returned when C(item.state) is set to C(directory). root: - description: allows filtering by original location + description: allows filtering by original location. path: - description: contains the relative path to root + description: contains the relative path to root. mode: - description: TODO + description: The permissions the resulting file or directory. state: description: TODO owner: - description: TODO + description: Name of the user that owns the file/directory. group: - description: TODO + description: Name of the group that owns the file/directory. seuser: - description: TODO + description: The user part of the SELinux file context. serole: - description: TODO + description: The role part of the SELinux file context. setype: - description: TODO + description: The type part of the SELinux file context. selevel: - description: TODO + description: The level part of the SELinux file context. uid: - description: TODO + description: Owner ID of the file/directory. gid: - description: TODO + description: Group ID of the file/directory. size: - description: TODO + description: Size of the target. mtime: - description: TODO + description: Time of last modification. ctime: - description: TODO + description: Time of last metadata update or creation (depends on OS). """ import os import pwd