From 40d22be2ef8519d90dee293e399552e8d1c92dd7 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 29 Oct 2015 09:02:11 -0400 Subject: 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 : --- lib/ansible/cli/pull.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py index 6caa8525db..0e10b59cba 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -50,7 +50,7 @@ class PullCLI(CLI): ''' create an options parser for bin/ansible ''' self.parser = CLI.base_parser( - usage='%prog [options]', + usage='%prog -d -U [options]', connect_opts=True, vault_opts=True, runtask_opts=True, @@ -91,8 +91,8 @@ class PullCLI(CLI): if not self.options.url: raise AnsibleOptionsError("URL for repository not specified, use -h for help") - if len(self.args) != 1: - raise AnsibleOptionsError("Missing target hosts") + if not self.options.dest: + raise AnsibleOptionsError("Destination directory for checkout not specified, use -h for help") 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))) @@ -114,7 +114,7 @@ class PullCLI(CLI): # Now construct the ansible command node = platform.node() 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 if self.options.verbosity > 0: base_opts += ' -%s' % ''.join([ "v" for x in range(0, self.options.verbosity) ]) -- cgit v1.2.1 From 9f148fc0463c0875a8eb192de8c37cb03f0adfc0 Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 29 Oct 2015 16:28:10 -0400 Subject: removed requirement of destination and set documented default --- docs/man/man1/ansible-pull.1.asciidoc.in | 2 +- lib/ansible/cli/pull.py | 8 +++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/docs/man/man1/ansible-pull.1.asciidoc.in b/docs/man/man1/ansible-pull.1.asciidoc.in index bc7de64ada..333b8e34e0 100644 --- a/docs/man/man1/ansible-pull.1.asciidoc.in +++ b/docs/man/man1/ansible-pull.1.asciidoc.in @@ -13,7 +13,7 @@ ansible-pull - pull playbooks from VCS server and run them using this machine as SYNOPSIS -------- -ansible-pull -d DEST -U URL [options] [ ] +ansible-pull -U URL [options] [ ] DESCRIPTION diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py index 0e10b59cba..6bca460770 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -50,7 +50,7 @@ class PullCLI(CLI): ''' create an options parser for bin/ansible ''' self.parser = CLI.base_parser( - usage='%prog -d -U [options]', + usage='%prog -U [options]', connect_opts=True, vault_opts=True, runtask_opts=True, @@ -67,7 +67,7 @@ class PullCLI(CLI): help='sleep for random interval (between 0 and n number of seconds) before starting. This is a useful way to disperse git requests') self.parser.add_option('-f', '--force', dest='force', default=False, action='store_true', help='run the playbook even if the repository could not be updated') - self.parser.add_option('-d', '--directory', dest='dest', default=None, help='directory to checkout repository to') + self.parser.add_option('-d', '--directory', dest='dest', default='~/.ansible/pull', help='directory to checkout repository to') self.parser.add_option('-U', '--url', dest='url', default=None, help='URL of the playbook repository') self.parser.add_option('-C', '--checkout', dest='checkout', help='branch/tag/commit to checkout. ' 'Defaults to behavior of repository module.') @@ -91,9 +91,6 @@ class PullCLI(CLI): if not self.options.url: raise AnsibleOptionsError("URL for repository not specified, use -h for help") - if not self.options.dest: - raise AnsibleOptionsError("Destination directory for checkout not specified, use -h for help") - 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))) @@ -129,6 +126,7 @@ class PullCLI(CLI): #TODO: enable more repo modules hg/svn? if self.options.module_name == 'git': repo_opts = "name=%s dest=%s" % (self.options.url, self.options.dest) + print(repo_opts) if self.options.checkout: repo_opts += ' version=%s' % self.options.checkout -- cgit v1.2.1 From 237f8c9df79b63d3c28672f533e4b7211874ad3f Mon Sep 17 00:00:00 2001 From: Brian Coca Date: Thu, 29 Oct 2015 20:34:55 -0400 Subject: removed debug print --- lib/ansible/cli/pull.py | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py index 6bca460770..c163b3ef0b 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -126,7 +126,6 @@ class PullCLI(CLI): #TODO: enable more repo modules hg/svn? if self.options.module_name == 'git': repo_opts = "name=%s dest=%s" % (self.options.url, self.options.dest) - print(repo_opts) if self.options.checkout: repo_opts += ' version=%s' % self.options.checkout -- cgit v1.2.1