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
899 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
1,029 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,460 points
4,494 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
1,135 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
4,155 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
4,036 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,224 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,464 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