Skip to content

Commit

Permalink
make ansible-pull clone only once
Browse files Browse the repository at this point in the history
* fixes ansible#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
  • Loading branch information
Robin Roth committed Dec 28, 2015
1 parent c489b27 commit 8ec2031
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/ansible/cli/pull.py
Expand Up @@ -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) ])
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 8ec2031

Please sign in to comment.