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 * better fix * qfq9
This commit is contained in:
parent
219a6a67f1
commit
fc745920c7
1 changed files with 22 additions and 11 deletions
|
@ -67,6 +67,21 @@ class PullCLI(CLI):
|
||||||
"look for a playbook based on the host's fully-qualified domain name,"
|
"look for a playbook based on the host's fully-qualified domain name,"
|
||||||
'on the host hostname and finally a playbook named *local.yml*.', }
|
'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):
|
def parse(self):
|
||||||
''' create an options parser for bin/ansible '''
|
''' create an options parser for bin/ansible '''
|
||||||
|
|
||||||
|
@ -158,15 +173,7 @@ class PullCLI(CLI):
|
||||||
|
|
||||||
# Attempt to use the inventory passed in as an argument
|
# Attempt to use the inventory passed in as an argument
|
||||||
# It might not yet have been downloaded so use localhost as default
|
# It might not yet have been downloaded so use localhost as default
|
||||||
inv_opts = ''
|
inv_opts = self._get_inv_cli()
|
||||||
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,'"
|
|
||||||
|
|
||||||
# FIXME: enable more repo modules hg/svn?
|
# FIXME: enable more repo modules hg/svn?
|
||||||
if self.options.module_name == 'git':
|
if self.options.module_name == 'git':
|
||||||
|
@ -231,8 +238,7 @@ class PullCLI(CLI):
|
||||||
if self.options.vault_password_files:
|
if self.options.vault_password_files:
|
||||||
for vault_password_file in self.options.vault_password_files:
|
for vault_password_file in self.options.vault_password_files:
|
||||||
cmd += " --vault-password-file=%s" % vault_password_file
|
cmd += " --vault-password-file=%s" % vault_password_file
|
||||||
if inv_opts:
|
|
||||||
cmd += ' %s' % inv_opts
|
|
||||||
for ev in self.options.extra_vars:
|
for ev in self.options.extra_vars:
|
||||||
cmd += ' -e "%s"' % ev
|
cmd += ' -e "%s"' % ev
|
||||||
if self.options.ask_sudo_pass or self.options.ask_su_pass or self.options.become_ask_pass:
|
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)
|
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
|
# RUN THE PLAYBOOK COMMAND
|
||||||
display.debug("running ansible-playbook to do actual work")
|
display.debug("running ansible-playbook to do actual work")
|
||||||
display.debug('EXEC: %s' % cmd)
|
display.debug('EXEC: %s' % cmd)
|
||||||
|
|
Loading…
Reference in a new issue