Use type='path' for path arguments for git module

This commit is contained in:
Michael Scherer 2016-03-29 08:50:09 +02:00
parent d4285b5f21
commit 870311748f

View file

@ -660,7 +660,7 @@ def verify_commit_sign(git_path, module, dest, version):
def main(): def main():
module = AnsibleModule( module = AnsibleModule(
argument_spec = dict( argument_spec = dict(
dest=dict(), dest=dict(type='path'),
repo=dict(required=True, aliases=['name']), repo=dict(required=True, aliases=['name']),
version=dict(default='HEAD'), version=dict(default='HEAD'),
remote=dict(default='origin'), remote=dict(default='origin'),
@ -672,9 +672,9 @@ def main():
update=dict(default='yes', type='bool'), update=dict(default='yes', type='bool'),
verify_commit=dict(default='no', type='bool'), verify_commit=dict(default='no', type='bool'),
accept_hostkey=dict(default='no', type='bool'), accept_hostkey=dict(default='no', type='bool'),
key_file=dict(default=None, required=False), key_file=dict(default=None, type='path', required=False),
ssh_opts=dict(default=None, required=False), ssh_opts=dict(default=None, required=False),
executable=dict(default=None), executable=dict(default=None, type='path'),
bare=dict(default='no', type='bool'), bare=dict(default='no', type='bool'),
recursive=dict(default='yes', type='bool'), recursive=dict(default='yes', type='bool'),
track_submodules=dict(default='no', type='bool'), track_submodules=dict(default='no', type='bool'),
@ -706,16 +706,11 @@ def main():
if not dest and allow_clone: if not dest and allow_clone:
module.fail_json(msg="the destination directory must be specified unless clone=no") module.fail_json(msg="the destination directory must be specified unless clone=no")
elif dest: elif dest:
dest = os.path.abspath(os.path.expanduser(dest))
if bare: if bare:
gitconfig = os.path.join(dest, 'config') gitconfig = os.path.join(dest, 'config')
else: else:
gitconfig = os.path.join(dest, '.git', 'config') gitconfig = os.path.join(dest, '.git', 'config')
# make sure the key_file path is expanded for ~ and $HOME
if key_file is not None:
key_file = os.path.abspath(os.path.expanduser(key_file))
# create a wrapper script and export # create a wrapper script and export
# GIT_SSH=<path> as an environment variable # GIT_SSH=<path> as an environment variable
# for git to use the wrapper script # for git to use the wrapper script