diff --git a/contrib/inventory_builder/inventory.py b/contrib/inventory_builder/inventory.py index 106f9eeea..76e7c0c46 100644 --- a/contrib/inventory_builder/inventory.py +++ b/contrib/inventory_builder/inventory.py @@ -83,11 +83,15 @@ class KubesprayInventory(object): self.config_file = config_file self.yaml_config = {} loadPreviousConfig = False + printHostnames = False # See whether there are any commands to process if changed_hosts and changed_hosts[0] in AVAILABLE_COMMANDS: if changed_hosts[0] == "add": loadPreviousConfig = True changed_hosts = changed_hosts[1:] + elif changed_hosts[0] == "print_hostnames": + loadPreviousConfig = True + printHostnames = True else: self.parse_command(changed_hosts[0], changed_hosts[1:]) sys.exit(0) @@ -105,6 +109,10 @@ class KubesprayInventory(object): print(e) sys.exit(1) + if printHostnames: + self.print_hostnames() + sys.exit(0) + self.ensure_required_groups(ROLES) if changed_hosts: