Manage Users Programmatically

I’m looking for a way to programmatically create/delete and especially revoke admin permissions to particular users.

I’d love an ansible module but even lacking that is there a way to use the discourse API to say given user Bob to grant/revoke moderation and admin privileges?

I could make an ansible module to do that. It might be easier to run a rails command in the container rather than use the API, though I haven’t looked to see for sure. I’ve used both methods for other automatons. If you’ve a budget message me or find my contact info in my profile.