fixes options for ansible pull

* remove requirement for host patterns, use the defaults
 * require destination directory (None in cwd is not a good default)
 * fixed usage messages
 * updated default inventory to use , and not deprecated :
This commit is contained in:
Brian Coca 2015-10-29 09:02:11 -04:00
parent b73941b95f
commit 40d22be2ef

View file

@ -50,7 +50,7 @@ class PullCLI(CLI):
''' create an options parser for bin/ansible ''' ''' create an options parser for bin/ansible '''
self.parser = CLI.base_parser( self.parser = CLI.base_parser(
usage='%prog <host-pattern> [options]', usage='%prog -d <destdir> -U <repository> [options]',
connect_opts=True, connect_opts=True,
vault_opts=True, vault_opts=True,
runtask_opts=True, runtask_opts=True,
@ -91,8 +91,8 @@ class PullCLI(CLI):
if not self.options.url: if not self.options.url:
raise AnsibleOptionsError("URL for repository not specified, use -h for help") raise AnsibleOptionsError("URL for repository not specified, use -h for help")
if len(self.args) != 1: if not self.options.dest:
raise AnsibleOptionsError("Missing target hosts") raise AnsibleOptionsError("Destination directory for checkout not specified, use -h for help")
if self.options.module_name not in self.SUPPORTED_REPO_MODULES: if self.options.module_name not in self.SUPPORTED_REPO_MODULES:
raise AnsibleOptionsError("Unsuported repo module %s, choices are %s" % (self.options.module_name, ','.join(self.SUPPORTED_REPO_MODULES))) raise AnsibleOptionsError("Unsuported repo module %s, choices are %s" % (self.options.module_name, ','.join(self.SUPPORTED_REPO_MODULES)))
@ -114,7 +114,7 @@ class PullCLI(CLI):
# Now construct the ansible command # Now construct the ansible command
node = platform.node() node = platform.node()
host = socket.getfqdn() host = socket.getfqdn()
limit_opts = 'localhost:%s:127.0.0.1' % ':'.join(set([host, node, host.split('.')[0], node.split('.')[0]])) limit_opts = 'localhost,%s,127.0.0.1' % ','.join(set([host, node, host.split('.')[0], node.split('.')[0]]))
base_opts = '-c local "%s"' % limit_opts base_opts = '-c local "%s"' % limit_opts
if self.options.verbosity > 0: if self.options.verbosity > 0:
base_opts += ' -%s' % ''.join([ "v" for x in range(0, self.options.verbosity) ]) base_opts += ' -%s' % ''.join([ "v" for x in range(0, self.options.verbosity) ])