How can I create a new user using ansible ploybook

0 votes

So, I wanted to create a new user with password on a host machine using ansible.

This is the play I wrote:

hosts:appservers
user:test
sudo:yes
gather_facts:yes 
var :
    password:centos
task:
  - name: creating user
    user: name=john password={{password}}

after I executed the above playbook, I tried to login with that user on another server using:

[root]# su - test

But it didn't ask for password to login

[test@localhost ~]$ 

Why isn't it asking for password?

Mar 29, 2018 in Ansible by ffdfd
• 5,550 points
665 views

1 answer to this question.

0 votes

You're switching from the root user. Root doesn't require passwords to switch users. If you want it to ask for a password, try to SSH into the host machine from your control machine using:

ssh test@localhost

answered Mar 29, 2018 by DareDev
• 6,890 points

Related Questions In Ansible

0 votes
1 answer

How to create a new encrpted file using Ansible Vault?

If you are creating a new file ...READ MORE

answered Jan 29, 2019 in Ansible by Kyraa
756 views
0 votes
1 answer

How to create a user using Ansible Playbook?

Hi@akhtar, You can use the user module in ...READ MORE

answered Sep 1, 2020 in Ansible by MD
• 95,440 points
4,093 views
0 votes
1 answer

devops , how to create user using ansible playbook

root doesn't need a password to switch ...READ MORE

answered Jul 16, 2018 in Ansible by Kalgi
• 2,680 points
959 views
0 votes
1 answer

How do I wget a file from web server using shell in the ansible playbook

Hey Ayaan, you could probably use this ...READ MORE

answered Jan 24, 2019 in Ansible by Anushri
3,877 views
+15 votes
2 answers

Git management technique when there are multiple customers and need multiple customization?

Consider this - In 'extended' Git-Flow, (Git-Multi-Flow, ...READ MORE

answered Mar 27, 2018 in DevOps & Agile by DragonLord999
• 8,450 points
3,531 views
+2 votes
1 answer
0 votes
1 answer

Using multiple config files using same template in a role in ansible

Go through this include_role module: tasks: - ...READ MORE

answered Jun 5, 2018 in Ansible by DareDev
• 6,890 points
4,012 views
+1 vote
2 answers

Running ansible command on a single server when it is deployed to multiple servers

You can try the run_once attribute: Example from ...READ MORE

answered Jun 14, 2018 in Ansible by DareDev
• 6,890 points
2,176 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP