|
|
|
@ -127,36 +127,12 @@ class InventoryCLI(CLI):
|
|
|
|
|
|
|
|
|
|
def run(self):
|
|
|
|
|
|
|
|
|
|
results = None
|
|
|
|
|
|
|
|
|
|
super(InventoryCLI, self).run()
|
|
|
|
|
|
|
|
|
|
# Initialize needed objects
|
|
|
|
|
if getattr(self, '_play_prereqs', False):
|
|
|
|
|
self.loader, self.inventory, self.vm = self._play_prereqs(self.options)
|
|
|
|
|
else:
|
|
|
|
|
# fallback to pre 2.4 way of initialzing
|
|
|
|
|
from ansible.vars import VariableManager
|
|
|
|
|
from ansible.inventory import Inventory
|
|
|
|
|
|
|
|
|
|
self._new_api = False
|
|
|
|
|
self.loader = DataLoader()
|
|
|
|
|
self.vm = VariableManager()
|
|
|
|
|
|
|
|
|
|
# use vault if needed
|
|
|
|
|
if self.options.vault_password_file:
|
|
|
|
|
vault_pass = CLI.read_vault_password_file(self.options.vault_password_file, loader=self.loader)
|
|
|
|
|
elif self.options.ask_vault_pass:
|
|
|
|
|
vault_pass = self.ask_vault_passwords()
|
|
|
|
|
else:
|
|
|
|
|
vault_pass = None
|
|
|
|
|
|
|
|
|
|
if vault_pass:
|
|
|
|
|
self.loader.set_vault_password(vault_pass)
|
|
|
|
|
# actually get inventory and vars
|
|
|
|
|
results = None
|
|
|
|
|
|
|
|
|
|
self.inventory = Inventory(loader=self.loader, variable_manager=self.vm, host_list=self.options.inventory)
|
|
|
|
|
self.vm.set_inventory(self.inventory)
|
|
|
|
|
# Initialize needed objects
|
|
|
|
|
self.loader, self.inventory, self.vm = self._play_prereqs(self.options)
|
|
|
|
|
|
|
|
|
|
if self.options.host:
|
|
|
|
|
hosts = self.inventory.get_hosts(self.options.host)
|
|
|
|
|