HEX
Server: Apache
System: Linux server.enlacediseno.com 4.18.0-553.62.1.el8_10.x86_64 #1 SMP Wed Jul 16 04:08:25 EDT 2025 x86_64
User: maor (1069)
PHP: 7.3.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/salt/matchers/data_match.py
"""
This is the default data matcher.
"""

import fnmatch
import logging

import salt.loader
import salt.utils.data
import salt.utils.minions
import salt.utils.network

log = logging.getLogger(__name__)


def match(tgt, functions=None, opts=None, minion_id=None):
    """
    Match based on the local data store on the minion
    """
    if not opts:
        opts = __opts__
    if functions is None:
        utils = salt.loader.utils(opts)
        functions = salt.loader.minion_mods(opts, utils=utils)
    comps = tgt.split(":")
    if len(comps) < 2:
        return False
    val = functions["data.getval"](comps[0])
    if val is None:
        # The value is not defined
        return False
    if isinstance(val, list):
        # We are matching a single component to a single list member
        for member in val:
            if fnmatch.fnmatch(str(member).lower(), comps[1].lower()):
                return True
        return False
    if isinstance(val, dict):
        if comps[1] in val:
            return True
        return False
    return bool(fnmatch.fnmatch(val, comps[1]))