mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
implemented 'inventory_file' variable. Closes GH-3789.
This commit is contained in:
parent
ceff3b6ba3
commit
e8272e365d
3 changed files with 13 additions and 0 deletions
|
@ -397,6 +397,12 @@ class Inventory(object):
|
||||||
return cwd
|
return cwd
|
||||||
return dname
|
return dname
|
||||||
|
|
||||||
|
def src(self):
|
||||||
|
""" if inventory came from a file, what's the directory and file name? """
|
||||||
|
if not self.is_file():
|
||||||
|
return None
|
||||||
|
return self.host_list
|
||||||
|
|
||||||
def playbook_basedir(self):
|
def playbook_basedir(self):
|
||||||
""" returns the directory of the current playbook """
|
""" returns the directory of the current playbook """
|
||||||
return self._playbook_basedir
|
return self._playbook_basedir
|
||||||
|
|
|
@ -140,6 +140,10 @@ class PlayBook(object):
|
||||||
vars = extra_vars.copy()
|
vars = extra_vars.copy()
|
||||||
if self.inventory.basedir() is not None:
|
if self.inventory.basedir() is not None:
|
||||||
vars['inventory_dir'] = self.inventory.basedir()
|
vars['inventory_dir'] = self.inventory.basedir()
|
||||||
|
|
||||||
|
if self.inventory.src() is not None:
|
||||||
|
vars['inventory_file'] = self.inventory.src()
|
||||||
|
|
||||||
self.filename = playbook
|
self.filename = playbook
|
||||||
(self.playbook, self.play_basedirs) = self._load_playbook_from_file(playbook, vars)
|
(self.playbook, self.play_basedirs) = self._load_playbook_from_file(playbook, vars)
|
||||||
ansible.callbacks.load_callback_plugins()
|
ansible.callbacks.load_callback_plugins()
|
||||||
|
|
|
@ -410,6 +410,9 @@ class Runner(object):
|
||||||
if self.inventory.basedir() is not None:
|
if self.inventory.basedir() is not None:
|
||||||
inject['inventory_dir'] = self.inventory.basedir()
|
inject['inventory_dir'] = self.inventory.basedir()
|
||||||
|
|
||||||
|
if self.inventory.src() is not None:
|
||||||
|
inject['inventory_file'] = self.inventory.src()
|
||||||
|
|
||||||
# late processing of parameterized sudo_user
|
# late processing of parameterized sudo_user
|
||||||
if self.sudo_user is not None:
|
if self.sudo_user is not None:
|
||||||
self.sudo_user = template.template(self.basedir, self.sudo_user, inject)
|
self.sudo_user = template.template(self.basedir, self.sudo_user, inject)
|
||||||
|
|
Loading…
Reference in a new issue