Hi all
I want to add users via commands
all - user -a “name=test password=test” -s -K
is not workingplease help.
.
Hi all
I want to add users via commands
all - user -a “name=test password=test” -s -K
is not workingplease help.
.
Hey Tcpip,
Can you please elaborate what exactly error you are getting after running this command because its working fine for me.
You need to provide more info like
the env (os, distro, version, etc) you are running ansible from
the full output (with the verbosity level raised by adding the ‘-vvvv’ cli opts to this command)
what you expect to happen
Hello Soniya,
This is the output I have and for what I can see none of my commands are working.
Servers 14.04
2.3.1.0
version = 2.7.6
Thanks!
This is the output I have
Loading callback plugin minimal of type , v20 from /usr/lib/python27/-packages//plugins/callback/init
META: handlers
Using module file /usr/lib/python27/-packages//modules/system/user
<172.22.15.3> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.22.15.3> EXEC /bin/sh -c ‘echo ~ && sleep 0’
Using module file /usr/lib/python27/-packages//modules/system/user
<172.22.14.3> ESTABLISH LOCAL CONNECTION FOR USER: root
<172.22.14.3> EXEC /bin/sh -c ‘echo ~ && sleep 0’
<172.22.14.3> EXEC /bin/sh -c ’ 77 && mkdir -p “echo /home///tmp/--1503561664.69-1922608506894
” && echo --1503561664.69-1922608506894=“echo /home///tmp/--1503561664.69-1922608506894
” && sleep 0’
<172.22.15.3> EXEC /bin/sh -c ’ 77 && mkdir -p “echo /home///tmp/--1503561664.68-54531949999364
” && echo --1503561664.68-54531949999364=“echo /home///tmp/--1503561664.68-54531949999364
” && sleep 0’
<172.22.14.3> PUT /tmp/tmpqpuHN1 TO /home///tmp/–1503561664.69-1922608506894/user
<172.22.14.3> EXEC /bin/sh -c ‘chmod u+x /home/juraj/.ansible/tmp/ansible-tmp-1503561664.69-1922608506894/ /home/juraj/.ansible/tmp/ansible-tmp-1503561664.69-1922608506894/user.py && sleep 0’
<172.22.15.3> PUT /tmp/ TO /home///tmp/–1503561664.68-54531949999364/user
<172.22.15.3> EXEC /bin/sh -c ‘chmod u+x /home/juraj/.ansible/tmp/ansible-tmp-1503561664.68-54531949999364/ /home/juraj/.ansible/tmp/ansible-tmp-1503561664.68-54531949999364/user.py && sleep 0’
<172.22.14.3> EXEC /bin/sh -c ‘/usr/bin/python /home/juraj/.ansible/tmp/ansible-tmp-1503561664.69-1922608506894/user.py; rm -rf “/home/juraj/.ansible/tmp/ansible-tmp-1503561664.69-1922608506894/” > /dev/null 2>&1 && sleep 0’
<172.22.15.3> EXEC /bin/sh -c ‘/usr/bin/python /home/juraj/.ansible/tmp/ansible-tmp-1503561664.68-54531949999364/user.py; rm -rf “/home/juraj/.ansible/tmp/ansible-tmp-1503561664.68-54531949999364/” > /dev/null 2>&1 && sleep 0’
Ubu1 | SUCCESS => {
“”: false,
“”: false,
“”: “”,
“”: 1001,
“”: “/home/",
“”: {
“module_args”: {
“”: false,
“”: null,
“”: true,
“”: null,
“”: false,
“generate_ssh_key”: null,
“”: null,
“”: null,
“”: null,
“login_class”: null,
“move_home”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“non_unique”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“”: false,
“”: null,
“”: null,
“”: null,
“ssh_key_bits”: 0,
“ssh_key_comment”: "-generated on ",
“ssh_key_file”: null,
“ssh_key_passphrase”: null,
“ssh_key_type”: “”,
“”: “present”,
“”: false,
“”: null,
“update_password”: “always”
}
},
“move_home”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“”: “NOT_LOGGING_PASSWORD”,
“”: “/bin/bash”,
“”: “present”,
“”: 1001
}
Ubu2 | SUCCESS => {
“”: false,
“”: false,
“”: “”,
“”: 1001,
“”: "/home/”,
“”: {
“module_args”: {
“”: false,
“”: null,
“”: true,
“”: null,
“”: false,
“generate_ssh_key”: null,
“”: null,
“”: null,
“”: null,
“login_class”: null,
“move_home”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“non_unique”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“”: false,
“”: null,
“”: null,
“”: null,
“ssh_key_bits”: 0,
“ssh_key_comment”: "-generated on ",
“ssh_key_file”: null,
“ssh_key_passphrase”: null,
“ssh_key_type”: “”,
“”: “present”,
“”: false,
“”: null,
“update_password”: “always”
}
},
“move_home”: false,
“”: “VALUE_SPECIFIED_IN_NO_LOG_PARAMETER”,
“”: “NOT_LOGGING_PASSWORD”,
“”: “/bin/bash”,
“”: “present”,
“”: 1001
}
These logs shows that your user is created successfully.
if you are not able to check the user whether it is created or not than you can see the output of this command
output of this command should be like this:
test:x:1001:1001::/home/test:
And if any query please revert
Hello,
Yes the logs when I check the remote server nothing is created-
.!!
This two lines in your log indicate you are using connection=local so
everything run on localhost and not on the remote host.
So if you check localhost you'll see the users are created there.
how r u verifying that user is created or not?
can you please share your command from which you are verifying and also the output of
try to login with the user/pass and is not working then I just do
/etc/password
.
That Will be in my host file what change should I do to make this work?
Thanks
hey,
the problem may be is in your password generation, may be your user has been created without password
you can check that by these commands:
user has been created but without password:
# id test
uid=229(test) gid=1(test)
# grep -q test /etc/security/passwd && echo "password OK" || echo "NO password"
NO password
then I just do more /etc/password
it is /etc/passwd.
ansible all -i hostfile -m user -a “name=test password=test” -s -K
or
ansible all -i 192.168.11.11, -m user -a “name=test password=test” -s -K
there must be a comma after the ip because its a tuple.
It will be in your inventory.
It would be easier if you could show us the entries for those two hosts, but I
guess you have ansible_connection=local, just remove ansible_connection,
default it is set to ssh.
Hello
But I was testing but I can’t see the home user. I was also trying to do copy files I have a successful out put but is not copying any file.
Thanks in advance
I guess you did not understand what I wrote in my previous mail.
It's obviously an error in your configuration, so you need to post your
inventory file, without it this will be a guessing game and that is a game I
don't play.
more /etc/ansible/hosts
[all:vars]
ansible_connection=local
username=admin
password=admin
[defaults]
host_key_checking = False
[router]
SW-LAB001 ansible_host=10.1.99.120
[linux]
pod1 ansible_host=10.1.108.105
pod2 ansible_host=10.1.108.128
pod3 ansible_host=10.1.108.132
pod4 ansible_host=10.1.108.129
pod5 ansible_host=10.1.108.133
pod6 ansible_host=10.1.108.131
pod7 ansible_host=10.1.108.130
pod8 ansible_host=10.1.108.110
pod9 ansible_host=10.1.108.111
pod10 ansible_host=10.1.108.112
And here we have the reason.
Here you say, all host should use ansible_connection=local aka run all task on
all host on localhost.
Remove that line and it will work as expected.
Hello Kai,
First of all thanks for your time and help, I will try the changes tonight and send you tomorrow the update.!
!
Hello Kai
Thanks for your tips, it worked but I have one question, when I remove that line I start having ssh issue to my network device.
ssh unable to connect, I add back that line and it starts working.
Thanks. !!!
That's because most network equipment doesn't have python installed so the
different module in Ansible use cli and/or api.
So, in your inventory I guess this is the one.
[router]
SW-LAB001 ansible_host=10.1.99.120
You have to option, add ansible_connection=local to every host that need it in
your inventory.
Or to the group
[router:vars]
ansible_connection=local