|
|
@ -95,6 +95,15 @@ options:
|
|
|
|
description:
|
|
|
|
description:
|
|
|
|
- if C(yes), repository will be created as a bare repo, otherwise
|
|
|
|
- if C(yes), repository will be created as a bare repo, otherwise
|
|
|
|
it will be a standard repo with a workspace.
|
|
|
|
it will be a standard repo with a workspace.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
recursive:
|
|
|
|
|
|
|
|
required: false
|
|
|
|
|
|
|
|
default: "yes"
|
|
|
|
|
|
|
|
choices: [ "yes", "no" ]
|
|
|
|
|
|
|
|
version_added: "1.5"
|
|
|
|
|
|
|
|
description:
|
|
|
|
|
|
|
|
- if C(no), repository will be cloned without the --recursive
|
|
|
|
|
|
|
|
option, skipping sub-modules.
|
|
|
|
notes:
|
|
|
|
notes:
|
|
|
|
- "If the task seems to be hanging, first verify remote host is in C(known_hosts).
|
|
|
|
- "If the task seems to be hanging, first verify remote host is in C(known_hosts).
|
|
|
|
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
|
|
|
|
SSH will prompt user to authorize the first contact with a remote host. To avoid this prompt,
|
|
|
@ -125,7 +134,8 @@ def get_version(git_path, dest, ref="HEAD"):
|
|
|
|
sha = os.popen(cmd).read().rstrip("\n")
|
|
|
|
sha = os.popen(cmd).read().rstrip("\n")
|
|
|
|
return sha
|
|
|
|
return sha
|
|
|
|
|
|
|
|
|
|
|
|
def clone(git_path, module, repo, dest, remote, depth, version, bare, reference):
|
|
|
|
def clone(git_path, module, repo, dest, remote, depth, version, bare,
|
|
|
|
|
|
|
|
reference, recursive):
|
|
|
|
''' makes a new git repo if it does not already exist '''
|
|
|
|
''' makes a new git repo if it does not already exist '''
|
|
|
|
dest_dirname = os.path.dirname(dest)
|
|
|
|
dest_dirname = os.path.dirname(dest)
|
|
|
|
try:
|
|
|
|
try:
|
|
|
@ -137,7 +147,9 @@ def clone(git_path, module, repo, dest, remote, depth, version, bare, reference)
|
|
|
|
if bare:
|
|
|
|
if bare:
|
|
|
|
cmd.append('--bare')
|
|
|
|
cmd.append('--bare')
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
cmd.extend([ '--origin', remote, '--recursive' ])
|
|
|
|
cmd.extend([ '--origin', remote ])
|
|
|
|
|
|
|
|
if recursive:
|
|
|
|
|
|
|
|
cmd.extend([ '--recursive' ])
|
|
|
|
if is_remote_branch(git_path, module, dest, repo, version) \
|
|
|
|
if is_remote_branch(git_path, module, dest, repo, version) \
|
|
|
|
or is_remote_tag(git_path, module, dest, repo, version):
|
|
|
|
or is_remote_tag(git_path, module, dest, repo, version):
|
|
|
|
cmd.extend([ '--branch', version ])
|
|
|
|
cmd.extend([ '--branch', version ])
|
|
|
@ -354,6 +366,7 @@ def main():
|
|
|
|
update=dict(default='yes', type='bool'),
|
|
|
|
update=dict(default='yes', type='bool'),
|
|
|
|
executable=dict(default=None),
|
|
|
|
executable=dict(default=None),
|
|
|
|
bare=dict(default='no', type='bool'),
|
|
|
|
bare=dict(default='no', type='bool'),
|
|
|
|
|
|
|
|
recursive=dict(default='yes', type='bool'),
|
|
|
|
),
|
|
|
|
),
|
|
|
|
supports_check_mode=True
|
|
|
|
supports_check_mode=True
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -368,6 +381,7 @@ def main():
|
|
|
|
bare = module.params['bare']
|
|
|
|
bare = module.params['bare']
|
|
|
|
reference = module.params['reference']
|
|
|
|
reference = module.params['reference']
|
|
|
|
git_path = module.params['executable'] or module.get_bin_path('git', True)
|
|
|
|
git_path = module.params['executable'] or module.get_bin_path('git', True)
|
|
|
|
|
|
|
|
recursive = module.params['recursive']
|
|
|
|
|
|
|
|
|
|
|
|
if bare:
|
|
|
|
if bare:
|
|
|
|
gitconfig = os.path.join(dest, 'config')
|
|
|
|
gitconfig = os.path.join(dest, 'config')
|
|
|
@ -384,7 +398,8 @@ def main():
|
|
|
|
if module.check_mode:
|
|
|
|
if module.check_mode:
|
|
|
|
remote_head = get_remote_head(git_path, module, dest, version, repo)
|
|
|
|
remote_head = get_remote_head(git_path, module, dest, version, repo)
|
|
|
|
module.exit_json(changed=True, before=before, after=remote_head)
|
|
|
|
module.exit_json(changed=True, before=before, after=remote_head)
|
|
|
|
clone(git_path, module, repo, dest, remote, depth, version, bare, reference)
|
|
|
|
clone(git_path, module, repo, dest, remote, depth, version, bare,
|
|
|
|
|
|
|
|
reference, recursive)
|
|
|
|
elif not update:
|
|
|
|
elif not update:
|
|
|
|
# Just return having found a repo already in the dest path
|
|
|
|
# Just return having found a repo already in the dest path
|
|
|
|
# this does no checking that the repo is the actual repo
|
|
|
|
# this does no checking that the repo is the actual repo
|
|
|
|