From e3a847a1425424d72c5fa2ad9c5de6a1f42bc9d0 Mon Sep 17 00:00:00 2001 From: Martin Krizek Date: Tue, 31 Oct 2017 13:56:40 +0100 Subject: [PATCH] git: fix archive when update is set to no (#31829) --- lib/ansible/modules/source_control/git.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/lib/ansible/modules/source_control/git.py b/lib/ansible/modules/source_control/git.py index f8c8ea97244..2d5bba68015 100644 --- a/lib/ansible/modules/source_control/git.py +++ b/lib/ansible/modules/source_control/git.py @@ -118,6 +118,8 @@ options: version_added: "1.2" description: - If C(no), do not retrieve new revisions from the origin repository + - Operations like archive will work on the existing (old) repository and might + not respond to changes to the options version or remote. executable: required: false default: null @@ -1087,6 +1089,15 @@ def main(): # requested. result['before'] = get_version(module, git_path, dest) result.update(after=result['before']) + if archive: + # Git archive is not supported by all git servers, so + # we will first clone and perform git archive from local directory + if module.check_mode: + result.update(changed=True) + module.exit_json(**result) + + create_archive(git_path, module, dest, archive, version, repo, result) + module.exit_json(**result) else: # else do a pull