HomeAutomation Tools

Ansible Playbook #2: Adding Multiple Users with Sudo access and private key

Ansible Playbook #2: Adding Multiple Users with Sudo access and private key
Like Tweet Pin it Share Share Email
Personal Development Category (English)728x90

The previous article, I have talked about the Ansible playbook introduction and YAML syntax. In this guide, I am going to show you the next level of writing Ansible playbook that is going to Adding Multiple Users and also add them to sudoers file (/etc/sudoers).  Check the below Ansible playbooks for clear understanding.

Adding Multiple Users

 

Suggestable Read:

1. Introduction and Installation & Configuration of Ansible 2.3 on CentOS/Redhat Linux 7

2. Configuring Ansible Dynamic Inventory for AWS EC2

3. Creating an Ansible static inventory with variables

4. Part #1: Getting Started with Ansible Ad-Hoc Commands

5. Part #2: Getting Started with Ansible Ad-Hoc Commands

Task Scenario: 

  1. Take a backup of sudoers file (/etc/sudoers).
  2.  Adding Multiple Users and Appending in Sudoers file with NOPASSWORD.
  3.  Users are allowed to log in with private keys only.
  4. Finally, verify the Sudoers file if any syntax error.

Above all the tasks are going to do with this playbook. Before executing the playbook.  Check the syntax error and do dry-run to make sure what you’re going to perform on the remote servers.

Here it is my complete playbook – useradd-with-sudo.yaml

 

Output: Adding Multiple Users

 

Conclusion:  That’s all about Adding Multiple Users. I will come up with more useful and interesting articles related to Ansible. Leave a comment on below if it helps you to get the knowledge on playing with Ansible.

Follow our Youtube Channel for more about Ansible Tutorials :

Check out the below Video for More about Ansible.

Comments (1)

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.