From 8ec20316d1e17267d42620fd0bcbe9f508fe8247 Mon Sep 17 00:00:00 2001 From: Robin Roth Date: Mon, 28 Dec 2015 16:52:47 +0100 Subject: [PATCH] make ansible-pull clone only once * fixes #13681 * the initial clone should only run once on localhost (remove 127.0.0.1 there) * the actual playbook run should be with all possible hostnames for localhost * '-l' options to ansible-pull are overwritten. Otherwise one could execute things with `-l otherhost -c local` which might lead to unexpected behavior --- 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 2571717766e7a2..f2920b6ce36441 100644 --- a/lib/ansible/cli/pull.py +++ b/lib/ansible/cli/pull.py @@ -130,7 +130,8 @@ def run(self): # 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_clone = 'localhost' + limit_opts_play = 'localhost,%s,127.0.0.1,::1' % ','.join(set([host, node, host.split('.')[0], node.split('.')[0]])) base_opts = '-c local ' if self.options.verbosity > 0: base_opts += ' -%s' % ''.join([ "v" for x in range(0, self.options.verbosity) ]) @@ -167,7 +168,7 @@ def run(self): bin_path = os.path.dirname(os.path.abspath(sys.argv[0])) cmd = '%s/ansible -i "%s" %s -m %s -a "%s" "%s"' % ( - bin_path, inv_opts, base_opts, self.options.module_name, repo_opts, limit_opts + bin_path, inv_opts, base_opts, self.options.module_name, repo_opts, limit_opts_clone ) for ev in self.options.extra_vars: @@ -208,8 +209,7 @@ def run(self): cmd += ' --ask-become-pass' if self.options.tags: cmd += ' -t "%s"' % self.options.tags - if self.options.subset: - cmd += ' -l "%s"' % self.options.subset + cmd += ' -l "%s"' % limit_opts_play os.chdir(self.options.dest)