Class InventoryParser.Inventory

java.lang.Object
com.scivicslab.turingworkflow.plugins.inventory.InventoryParser.Inventory
Enclosing class:
InventoryParser

public static class InventoryParser.Inventory extends Object
Represents a parsed Ansible inventory.

Stores the complete inventory structure including groups, hosts, global variables, group-specific variables, and host-specific variables. Variable precedence follows Ansible conventions: host vars override group vars, which override global vars.

Since:
1.0
  • Constructor Details

    • Inventory

      public Inventory()
  • Method Details

    • addGroup

      public void addGroup(String groupName)
      Registers a group name in the inventory, creating an empty host list if absent.
      Parameters:
      groupName - the name of the group to add
    • addHost

      public void addHost(String groupName, String hostname)
      Adds a host to the specified group.
      Parameters:
      groupName - the name of the group
      hostname - the hostname to add
    • addGlobalVar

      public void addGlobalVar(String key, String value)
      Adds a global variable (from the [all:vars] section).
      Parameters:
      key - the variable name
      value - the variable value
    • addGroupVar

      public void addGroupVar(String groupName, String key, String value)
      Adds a variable to the specified group's variable section.
      Parameters:
      groupName - the name of the group
      key - the variable name
      value - the variable value
    • addHostVar

      public void addHostVar(String hostname, String key, String value)
      Adds a host-specific variable.
      Parameters:
      hostname - the hostname to associate the variable with
      key - the variable name
      value - the variable value
    • getHosts

      public List<String> getHosts(String groupName)
      Gets the list of hosts belonging to the specified group.
      Parameters:
      groupName - the name of the group
      Returns:
      the list of hostnames in the group, or an empty list if the group does not exist
    • getGlobalVars

      public Map<String,String> getGlobalVars()
      Gets a defensive copy of all global variables.
      Returns:
      a new map containing all global variables
    • getGroupVars

      public Map<String,String> getGroupVars(String groupName)
      Gets a defensive copy of the variables for the specified group.
      Parameters:
      groupName - the name of the group
      Returns:
      a new map containing the group's variables, or an empty map if the group has no variables
    • getHostVars

      public Map<String,String> getHostVars(String hostname)
      Gets a defensive copy of the variables for the specified host.
      Parameters:
      hostname - the hostname
      Returns:
      a new map containing the host's variables, or an empty map if the host has no variables
    • getAllGroups

      public Map<String,List<String>> getAllGroups()
      Gets a defensive copy of all groups and their host lists.
      Returns:
      a new map of group names to their host lists