plasmabio / plasma

Plasma is an e-learning Jupyter-based platform for data analysis
https://docs.plasmabio.org
BSD 3-Clause "New" or "Revised" License
42 stars 12 forks source link

Create and delete multiple student users #199

Closed pierrepo closed 2 years ago

pierrepo commented 2 years ago

This PR handles issue #197

pierrepo commented 2 years ago

Example for user creation:

ansible-playbook students-create.yml -i hosts -u ubuntu -e @users-config.yml -e "studentdef=student-accounts.csv"

where student-accounts.csv is a CSV-formated file:

login,password,group
stu-megm1-01,fera4+BARE7=,megm1
stu-megm1-02,tysy9@TETE5+,megm1
stu-megm1-03,xazy5+VAZA2-,megm1
stu-megm1-04,vaze6-XEBA4=,megm1
stu-megm1-05,tyny6+VETA3@,megm1
stu-megm1-06,bysa5+ZYKE2+,megm1

To delete users, we use the students-delete.yml playbook:

ansible-playbook students-remove.yml -i hosts -u ubuntu -e "studentdef=student-accounts.csv"
jtpio commented 2 years ago

Thanks @pierrepo, looking good :+1:

We should also add that to the documentation for visibility.

pierrepo commented 2 years ago

Thanks @jtpio Can you please take care of the documentation part?

jtpio commented 2 years ago

@pierrepo do you have an example CSV file that we could use for the docs?

pierrepo commented 2 years ago

@jtpio sure. This one for instance:

login,password,group
stu-megm1-01,bn3r7RjtOyg15X,megm1
stu-megm1-02,2shgP3xK7aTuMN,megm1
stu-megm1-03,Kh5jn4GuEIFIzY,megm1
stu-megm1-04,g9gBHQjJ4VqQG1,megm1
stu-megm1-05,73O88oFb6B1TB0,megm1
stu-megm1-06,laZubrmgKBNg1x,megm1
stu-megm1-07,gAONEMsgdz28si,megm1
stu-megm1-08,tjlGadyELWj59M,megm1
stu-megm1-09,soIb4txJDPjo1d,megm1
stu-megm1-10,QjhalcW9Uq5wxo,megm1

Accounts for 10 students of group megm1 with randomly-generated passwords. It could be worth mentioning somewhere that passwords should not contain a comma, since comma is the field separator for CSV files.

jtpio commented 2 years ago

@pierrepo if you want to review the changes on ReadTheDocs: https://plasmabio--199.org.readthedocs.build/en/199/configuration/batch-users.html

I added some documentation in the Configuring section to avoid creating a new top-level entry in the navigation bar. There is a link at the bottom of the user creation page in the installation guide to point to the new page, for those who want to follow-up: https://plasmabio--199.org.readthedocs.build/en/199/install/users.html#creating-user-in-batches

pierrepo commented 2 years ago

Thanks @jtpio this looks very nice.

Maybe we should add somewhere that we can user extra parameters (disk quota for instance) when we create users:

ansible-playbook student-create.yml -u ubuntu -e "studentdef=students.csv" -e @students-config.yml

with students-config.yml being:

# default quotas for students
quota:
  soft: 200G
  hard: 250G
jtpio commented 2 years ago

Sounds good, just added the following note to the docs:

image

pierrepo commented 2 years ago

This is all good for me. Thanks @jtpio

jtpio commented 2 years ago

Alright thanks @pierrepo for the review!