def set_selinux_context(path,
                        user=None,
                        role=None,
                        type=None,    # pylint: disable=W0622
                        range=None):  # pylint: disable=W0622
    if not any((user, role, type, range)):
        return False

    cmd = ['chcon']
    if user:
        cmd.extend(['-u', user])
    if role:
        cmd.extend(['-r', role])
    if type:
        cmd.extend(['-t', type])
    if range:
        cmd.extend(['-l', range])
    cmd.append(path)

    ret = not __salt__['cmd.retcode'](cmd, python_shell=False)
    if ret:
        return get_selinux_context(path)
    else:
        return ret
Set a specific SELinux label on a given path
dataset/ETHPy150Open saltstack/salt/salt/modules/file.py/set_selinux_context