1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00

Remove dead code in ansible-inventory

This piece of code is only needed with ansible < 2.3.x (which is now EOL)
This commit is contained in:
Toshio Kuratomi 2018-12-17 15:06:52 -08:00
parent 9bc401a272
commit 40144c7486

View file

@ -127,36 +127,12 @@ class InventoryCLI(CLI):
def run(self): def run(self):
results = None
super(InventoryCLI, self).run() super(InventoryCLI, self).run()
results = None
# Initialize needed objects # Initialize needed objects
if getattr(self, '_play_prereqs', False): self.loader, self.inventory, self.vm = self._play_prereqs(self.options)
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
self.inventory = Inventory(loader=self.loader, variable_manager=self.vm, host_list=self.options.inventory)
self.vm.set_inventory(self.inventory)
if self.options.host: if self.options.host:
hosts = self.inventory.get_hosts(self.options.host) hosts = self.inventory.get_hosts(self.options.host)