11(batch-users)=
22
3- # Creating users in batches
3+ # Creating and deleting users in batches
44
55The {ref}` install-users ` section details how to create the initial list of users.
66
77However in some cases it is useful to have a more automated way to create (and delete) users
88in batches. For example when preparing and cleaning up a group of students at the beginning and end of a semester.
99
10- This section details how to create users defined in a CSV file using Ansible Playbooks.
10+ This section details how to create and delete users defined in a CSV file using Ansible Playbooks.
1111
1212## Creating the CSV File
1313
@@ -33,24 +33,19 @@ stu-megm1-10,QjhalcW9Uq5wxo,megm1
3333Since the fields in the CSV file are delimited by commas, passwords should not contain any `,` character.
3434````
3535
36- ## Running the playbooks
36+ ## Running the playbook to create users
3737
3838To create the users, go to the ` ansible/ ` folder and run the ` student-create.yml ` playbook with:
3939
4040``` sh
4141ansible-playbook student-create.yml -u ubuntu -e " studentdef=students.csv"
4242```
4343
44- It is also possible to delete the users from the same CSV definition, using the ` student-remove.yml ` playbook:
45-
46- ``` sh
47- ansible-playbook student-remove.yml -u ubuntu -e " studentdef=students.csv"
48- ```
4944
5045```` {note}
5146It is possible to pass additional parameters when creating users in batches.
5247
53- For example if you have a file defining disk quotas for a group of students:
48+ For example if you have a file `students-config.yml` defining disk quotas for a group of students:
5449
5550```yaml
5651# default quotas for students
@@ -61,7 +56,24 @@ quota:
6156
6257You can run the playbook and reference that extra file:
6358
64- ```bash
59+ ```sh
6560ansible-playbook student-create.yml -u ubuntu -e "studentdef=students.csv" -e @students-config.yml
6661```
62+ ````
63+
64+
65+ ## Running the playbook to delete users
66+
67+ To delete users, go to the ` ansible/ ` folder and run the ` student-remove.yml ` playbook with:
68+
69+ ``` sh
70+ ansible-playbook student-remove.yml -u ubuntu -e " studentdef=students.csv"
71+ ```
72+
73+ ```` {warning}
74+ You need to provide the exact same CSV file you used to create users in the first place.
75+ ````
76+
77+ ```` {warning}
78+ Please note that user home directories are deleted.
6779````
0 commit comments