Adding a new user to your system with ansible
Ansible is an open-source software provisioning, configuration management, and application-deployment tool. It runs on many Unix-like systems, and can configure both Unix-like systems as well as Microsoft Windows. It uses YAML syntax. The task is to add a new user to the system. The ansible user module can be used to accomplish this. The docs can be looked upon here - https://docs.ansible.com/ansible/latest/modules/user_module.html
The following command can be used to run the playbook -
➜ ~ ansible-playbook adduser.yaml -e "username=yourusername password=yourpassword shell=/path/to/shell" -K
Adding a user requires root privileges so this prompts for the password. (note that the current user needs to have access to sudo)
Now to switch to the newly created user we can use the following command -
➜ ~ sudo su - yourusername
This should now switch us to the newly created user.