Class InventoryParser

java.lang.Object
com.scivicslab.actoriac.InventoryParser

public class InventoryParser extends Object
Parser for Ansible inventory files in INI format.

This parser supports a subset of Ansible inventory file format. actor-IaC supports both Ansible-compatible syntax (ansible_*) and native syntax (actoriac_*).

Supported Features

  • Groups: [groupname]
  • Group variables: [groupname:vars]
  • Global variables: [all:vars]
  • Host-specific variables: hostname key=value
  • Comments: lines starting with # or ;

Supported Variables

Supported inventory variables
actor-IaCAnsibleDescription
actoriac_hostansible_hostActual hostname/IP to connect
actoriac_useransible_userSSH username
actoriac_portansible_portSSH port
actoriac_connectionansible_connectionConnection type (ssh/local)

Unsupported Ansible Features

The following Ansible features are NOT supported and will generate warnings:

  • Children groups: [group:children]
  • Range patterns: web[01:50].example.com
  • Privilege escalation: ansible_become, ansible_become_user
  • Python interpreter: ansible_python_interpreter
Author:
devteam@scivicslab.com
  • Field Details

  • Constructor Details

  • Method Details

    • parse

      Parses an Ansible inventory file.

      This method collects warnings for unsupported Ansible features. Warnings are stored in the returned InventoryParser.ParseResult and should be logged by the caller using the appropriate logging mechanism (e.g., DistributedLogStore).

      Parameters:
      input - the input stream of the inventory file
      Returns:
      the parse result containing inventory and any warnings
      Throws:
      IOException - if reading the file fails
    • checkUnsupportedVariable

      private static void checkUnsupportedVariable(String key, int lineNumber, Set<String> warnedVars, List<String> warnings)
      Checks if a variable is unsupported and adds a warning if so.
      Parameters:
      key - the variable name
      lineNumber - the line number for error reporting
      warnedVars - set of already warned variables (to avoid duplicate warnings)
      warnings - list to add warnings to
    • getUnsupportedVarSuggestion

      Returns a helpful suggestion for unsupported Ansible variables.