summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Coca <bcoca@users.noreply.github.com>2017-09-27 19:50:36 -0400
committerBrian Coca <brian.coca+git@gmail.com>2017-09-27 19:51:06 -0400
commitfb2a533b81007de0c943cae458177693b7eb66fd (patch)
treed97963b90134d7e099e2fe04558feaac91d0409a
parent5b081883183b4f4ddc72ca7fe81a69b269967e1f (diff)
downloadansible-fb2a533b81007de0c943cae458177693b7eb66fd.tar.gz
fixed pull's ansible/git invocation options (#30938)
* fixed ansible/git invocation options now falls back to using localhost as 'all' does not include implicit accidentally anymore fixes #30636 (cherry picked from commit fc745920c74f52e0ee6705808c01f8bdd4bed1cb)
-rw-r--r--CHANGELOG.md1
-rw-r--r--lib/ansible/cli/pull.py33
2 files changed, 23 insertions, 11 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 1188306da6..4c1ed84e82 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -53,6 +53,7 @@ Ansible Changes By Release
* fixed typo and missed include/import conversion in import_tasks docs
* updated porting docs with note about inventory_dir
* removed extension requirement for yaml inventory plugin to restore previous behaviour
+* fixed ansible-pull to now correctly deal with inventory
<sdfasdfsadfsdflkjsdfklj3oiqrua id="2.4"></a>
diff --git a/lib/ansible/cli/pull.py b/lib/ansible/cli/pull.py
index 38130fab7f..e29ac3174f 100644
--- a/lib/ansible/cli/pull.py
+++ b/lib/ansible/cli/pull.py
@@ -67,6 +67,21 @@ class PullCLI(CLI):
"look for a playbook based on the host's fully-qualified domain name,"
'on the host hostname and finally a playbook named *local.yml*.', }
+ def _get_inv_cli(self):
+
+ inv_opts = ''
+ if getattr(self.options, 'inventory'):
+ for inv in self.options.inventory:
+ if isinstance(inv, list):
+ inv_opts += " -i '%s' " % ','.join(inv)
+ elif ',' in inv or os.path.exists(inv):
+ inv_opts += ' -i %s ' % inv
+
+ if not inv_opts:
+ inv_opts = " -i localhost, "
+
+ return inv_opts
+
def parse(self):
''' create an options parser for bin/ansible '''
@@ -158,15 +173,7 @@ class PullCLI(CLI):
# Attempt to use the inventory passed in as an argument
# It might not yet have been downloaded so use localhost as default
- inv_opts = ''
- if getattr(self.options, 'inventory'):
- for inv in self.options.inventory:
- if isinstance(inv, list):
- inv_opts += " -i '%s' " % ','.join(inv)
- elif ',' in inv or os.path.exists(inv):
- inv_opts += ' -i %s ' % inv
- else:
- inv_opts = "-i 'localhost,'"
+ inv_opts = self._get_inv_cli()
# FIXME: enable more repo modules hg/svn?
if self.options.module_name == 'git':
@@ -231,8 +238,7 @@ class PullCLI(CLI):
if self.options.vault_password_files:
for vault_password_file in self.options.vault_password_files:
cmd += " --vault-password-file=%s" % vault_password_file
- if inv_opts:
- cmd += ' %s' % inv_opts
+
for ev in self.options.extra_vars:
cmd += ' -e "%s"' % ev
if self.options.ask_sudo_pass or self.options.ask_su_pass or self.options.become_ask_pass:
@@ -250,6 +256,11 @@ class PullCLI(CLI):
os.chdir(self.options.dest)
+ # redo inventory options as new files might exist now
+ inv_opts = self._get_inv_cli()
+ if inv_opts:
+ cmd += inv_opts
+
# RUN THE PLAYBOOK COMMAND
display.debug("running ansible-playbook to do actual work")
display.debug('EXEC: %s' % cmd)