Objective:
- Create a file under a common format (yml, json)
- Create a PostgreSQL role for each user un file
Description:
I'm trying to create alot of users and inserting them into their respective groups, the structure isn't very complicated, but my current issue, is trying to find documentation or a solution to achieve the objectives here. I don't know how to create this list, but indulge me in considering this:
example users.yml|json
```
------
# Classe roles
name: classeA
db: database
can_login: no
name: classeA
db: database
can_login: no
# Student roles
name: student1
db: database
login: yes
password: xxxx
member_of: classeA
name: student2
db: database
login: yes
db: school
password: xxxx
member_of: classeA
name: student3
db: database
login: yes
db: school
password: xxxx
member_of: classeA
```
Now, ansible, provides a way to create postgresql users like so
```
postgresql_user:
db: acme
name: django
password: ceec4eif7ya
priv: "CONNECT/products:ALL"
expires: "Jan 31 2020"
```
I've considered the following idea:
- using ansible.builtin.include_vars to read the yml file, insert data into a variable LIST, and foreach element in that list, call the postgresql_user module to create the user.
I would welcome any help regarding this.