need help in adding users in centos

General support questions
Post Reply
knzzz
Posts: 157
Joined: 2017/02/25 12:41:42

need help in adding users in centos

Post by knzzz » 2021/04/25 03:12:42

Hi Team,

i need to add users to the centos server using script , the script should

1. ask how many users to be added
2. it should ask us which user to be added to which group(one group or multiple group)
3.once it got the information about the users and group it should check already the user and group exist or not
4. Once the users and group validated it should ask to enter password for the users added

kindly assist in writing the script

Regards
Kanna

User avatar
jlehtone
Posts: 4523
Joined: 2007/12/11 08:17:33
Location: Finland

Re: need help in adding users in centos

Post by jlehtone » 2021/04/25 08:27:12

The point 3 feature -- change only if necessary -- is idempotency. One script that has that is called 'Ansible'.
It can create groups and accounts:
https://docs.ansible.com/ansible/latest ... odule.html
https://docs.ansible.com/ansible/latest ... odule.html

Note that Ansible does not ask from user. It uses variables that you define either in files or on command-line.

You can get Ansible with:

Code: Select all

sudo yum install centos-release-ansible-29
sudo yum install ansible

Post Reply