Ansible Tutorial - How to Use Ansible User and Group Module | Ansible Ad-Hoc Command

Linuxtopic
1









ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles
Ansible Tutorial : Ansible modules user & group

ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles







In this topic we will learn about how to manage user and group using ansible modules, we use following ansible module for it.




  • Ansible User Module

  • Ansible Group Module




User Management



User Module : It is used for user management, create user, delete user and more




To help ansible user module  



ansible-doc user





ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles
Ansible Tutorial - ansible-doc




To Check password algorithm of Hosts, its must require to generate password and set password of user because plan text password does not support.



ansible 172.17.20.98 -m shell -a "authconfig --test" | grep password











Generate password :



python -c "from passlib.hash import sha512_crypt; import getpass; print sha512_crypt.using(rounds=5000).hash(getpass.getpass())"


Password: **********


$6$O.RWXg/0E73uMPKe$DF.CGkdD0F/z6Q9Pww31mGxKvgRlhIN3bLXh2U/TKWTbSdax47xxrXe5nehSkxS.rrLdKeJr8rbC5ZwhMJRuC0








Create a User : Using hash password string in ansible



ansible 172.17.20.98 -m user -a 'name=lokcar password=$6$O.RWXg/0E73uMPKe$DF.CGkdD0F/z6Q9Pww31mGxKvgRlhIN3bLXh2U/TKWTbSdax47xxrXe5nehSkxS.rrLdKeJr8rbC5ZwhMJRuC0 state=present'







To Create a user with define shell and home directory



ansible 172.17.20.98 -m user -a 'name=lokesh1 password=$6$n2em3sW/g7aKU6Ek$LgIJnIfmQkCqry3gOHpe8zNodK6yQ01SL2737eYtxjuJtbP0tRo5HRaOlf6.OzjpThGIyHf0kj4dv8f/yA9CN1 state=present home=/tmp/ shell=/usr/bin/lshell'





ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles
Ansible Tutorial - Create User with define Shell and Directory 




Change user primary group


ansible 172.17.20.98 -m user -a "name=lokesh group=tesy"





ansible 172.17.20.98 -m user -a "name=lokesh groups=lokesh"







Add user in multiple groups


ansible 172.17.20.98 -m user -a "name=lokesh append=yes groups=lokesh,apache,ftp"


  


Deleting a user



ansible 172.17.20.98 -m user -a "name=ans2 state=absent"





ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles
Ansible Tutorial - Delete Users




Ansible Group Management :



To Create Group


ansible 172.17.20.98 -m group -a "name=ansible1"




ansible user module, ansible group module, ansible tutorial for beginners, ansible, ansible tutorial, ansible ad hoc commands, ansible modules, ansible example, ansible playbook tutorial, ansible linux, ansible best practices, ansible best practices, ansible playbook examples, ansible roles
Ansible Tutorial - Create Groups


   


Delete group


ansible 172.17.20.98 -m group -a "name=ansible1 state=absent"








Thanks

End of this ansble ad-hoc command and ansible modules, we need your support so i request you to please comment, share and like this post






www.linuxtopic.com


Post a Comment

1Comments

Post a Comment

#buttons=(Ok, Go it!) #days=(20)

Our website uses cookies to enhance your experience. Check Now
Ok, Go it!