def METHOD_NAME(bool_name, value, persistent=False):
    """
    Set the specified SELinux boolean to the desired state.
    + boolean: name of an SELinux boolean
    + state: 'on' or 'off'
    + persistent: whether to write updated policy or not
    Note: This operation requires root privileges.
    **Example:**
    .. code:: python
        selinux.boolean(
            name='Allow Apache to connect to LDAP server',
            'httpd_can_network_connect',
            'on',
            persistent=True
        )
    """
    _valid_states = ["on", "off"]
    if value not in _valid_states:
        raise ValueError(
            f'\'value\' must be one of \'{",".join(_valid_states)}\' but found \'{value}\'',
        )
    if host.get_fact(SEBoolean, METHOD_NAME=bool_name) != value:
        persist = "-P " if persistent else ""
        yield StringCommand("setsebool", f"{persist}{bool_name}", value)
        host.create_fact(SEBoolean, kwargs={"boolean": bool_name}, data=value)
    else:
        host.noop(f"boolean '{bool_name}' already had the value '{value}'")