import json
import yaml
import configparser


def parse_inventory_file(inventory_file: str) -> dict:
    """
    Reads inventory file (JSON, YAML, INI) and returns it as a dictionary
    :param inventory_file: Inventory file content
    :return: Inventory variables
    """
    # JSON
    try:
        conf_dict = json.loads(inventory_file)
        return conf_dict
    except json.decoder.JSONDecodeError:
        pass
    # YAML
    try:
        conf_dict = yaml.safe_load(inventory_file)
        return conf_dict
    except yaml.YAMLError:
        pass
    # INI
    try:
        config_parser = configparser.ConfigParser()
        config_parser.read_string(inventory_file)
        conf_dict = {section: dict(config_parser.items(section)) for section in config_parser.sections()}
        return conf_dict
    except configparser.Error:
        pass

    raise ValueError("Invalid inventory file provided: {}.".format(inventory_file))