Add passworddless sudo user via ansible for Ubuntu 22.04 VM's(for personal uses/learning purposes only)
For my learning environment, i needed to quickly and correctly add a passwordless sudo user(for Ubuntu 22.04 VM), since i'm learning ansible, i decided to write the necessary inventory and playbook file, after that i decided to make it customizable via a bash script. User can enter the new user details(name and password) and machine ssh connection information (ip, username and password). And this script first tests the connection via ansible's ping module, after successful operation, asks user to run the generated playbook(or exit and show the command to run the playbook)
These bash scripts:
- install python3,pip and sshpass(for ansible), and install ansible via pip
- asks user to enter the new user details (username and password) to generate the ansible playbook
- asks user to enter the remote machine information to generate the ansible inventory
- pings the inventory machines