From 1ddae11bd12b077ea2ead43c891328e8d40f4223 Mon Sep 17 00:00:00 2001 From: Toshio Kuratomi Date: Wed, 15 Apr 2015 09:24:45 -0700 Subject: [PATCH] Implement feature to return list of files in the archive --- lib/ansible/modules/files/unarchive.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/ansible/modules/files/unarchive.py b/lib/ansible/modules/files/unarchive.py index af9310679b6..ef30dc36122 100644 --- a/lib/ansible/modules/files/unarchive.py +++ b/lib/ansible/modules/files/unarchive.py @@ -3,6 +3,7 @@ # (c) 2012, Michael DeHaan # (c) 2013, Dylan Martin +# (c) 2015, Toshio Kuratomi # # This file is part of Ansible # @@ -50,6 +51,13 @@ options: required: no default: null version_added: "1.6" + list_files: + description: + - If set to True, return the list of files that are contained in the tarball. + required: false + choices: [ "yes", "no" ] + default: "no" + version_added: "2.0" author: Dylan Martin todo: - detect changed/unchanged for .zip files @@ -247,6 +255,7 @@ def main(): dest = dict(required=True), copy = dict(default=True, type='bool'), creates = dict(required=False), + list_files = dict(required=False, default=False, type='bool'), ), add_file_common_args=True, ) @@ -296,6 +305,9 @@ def main(): file_args['path'] = os.path.join(dest, filename) res_args['changed'] = module.set_fs_attributes_if_different(file_args, res_args['changed']) + if module.params['list_files']: + res_args['files'] = handler.files_in_archive + module.exit_json(**res_args) # import module snippets