Class InventoryParser.Inventory
java.lang.Object
com.scivicslab.turingworkflow.plugins.inventory.InventoryParser.Inventory
- Enclosing class:
InventoryParser
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 Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddGlobalVar(String key, String value) Adds a global variable (from the[all:vars]section).voidRegisters a group name in the inventory, creating an empty host list if absent.voidaddGroupVar(String groupName, String key, String value) Adds a variable to the specified group's variable section.voidAdds a host to the specified group.voidaddHostVar(String hostname, String key, String value) Adds a host-specific variable.Gets a defensive copy of all groups and their host lists.Gets a defensive copy of all global variables.getGroupVars(String groupName) Gets a defensive copy of the variables for the specified group.Gets the list of hosts belonging to the specified group.getHostVars(String hostname) Gets a defensive copy of the variables for the specified host.
-
Constructor Details
-
Inventory
public Inventory()
-
-
Method Details
-
addGroup
Registers a group name in the inventory, creating an empty host list if absent.- Parameters:
groupName- the name of the group to add
-
addHost
Adds a host to the specified group.- Parameters:
groupName- the name of the grouphostname- the hostname to add
-
addGlobalVar
Adds a global variable (from the[all:vars]section).- Parameters:
key- the variable namevalue- the variable value
-
addGroupVar
Adds a variable to the specified group's variable section.- Parameters:
groupName- the name of the groupkey- the variable namevalue- the variable value
-
addHostVar
Adds a host-specific variable.- Parameters:
hostname- the hostname to associate the variable withkey- the variable namevalue- the variable value
-
getHosts
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
Gets a defensive copy of all global variables.- Returns:
- a new map containing all global variables
-
getGroupVars
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
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
Gets a defensive copy of all groups and their host lists.- Returns:
- a new map of group names to their host lists
-