def create_authority_roles(roles, owner, plugin_title, creator):
    """
    Creates all of the necessary authority roles.
    :param creator:
    :param roles:
    :return:
    """
    role_objs = []
    for r in roles:
        role = role_service.get_by_name(r["name"])
        # error out if the role already exists, because we want a unique role per authority
        if role:
            raise Exception("Unable to create authority role {} because it already exists".format(r["name"]))
        role = role_service.create(
            r["name"],
            password=r["password"],
            description=f"Auto generated role for {plugin_title}",
            username=r["username"],
        )

        role_objs.append(role)

    # get or create a role for the owner
    owner_role = role_service.get_by_name(owner)
    if not owner_role:
        owner_role = role_service.create(
            owner, description=f"Auto generated role based on owner: {owner}"
        )

    role_objs.append(owner_role)
    return role_objs

    Creates all of the necessary authority roles.
    :param creator:
    :param roles:
    :return:
    
lemur/authorities/service.py