Yes, ansible use login root for SSH connection. But why should ansible
try
a different user?
There are many places user configuration can be done, anyway, have you
tried to add -vvvv to the command to get a more verbose output?
> Yes, ansible use login root for SSH connection. But why should
ansible try
> a different user?
There are many places user configuration can be done, anyway, have you
tried to add -vvvv to the command to get a more verbose output?
I did not specify a user anywhere. Whether in ssh_config nor in
Inventory nor with the command. Here is the output with -vvvv:
ansible host-group -vvvv -m ping
Using /etc/ansible/ansible.cfg as config file
Loaded callback minimal of type stdout, v2.0
<host1.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<host1.example.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r host1.example.com
'/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.87-148558126071189 `" && echo
ansible-tmp-1468943476.87-148558126071189="` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.87-148558126071189 `" ) &&
sleep 0'"'"''
<host2.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<host2.example.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r host2.example.com
'/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.87-38319674786550 `" && echo
ansible-tmp-1468943476.87-38319674786550="` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.87-38319674786550 `" ) &&
sleep 0'"'"''
<host-test.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<host-test.example.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r host-test.example.com
'/bin/sh -c '"'"'( umask 77 && mkdir -p "` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.88-266972946311694 `" && echo
ansible-tmp-1468943476.88-266972946311694="` echo
$HOME/.ansible/tmp/ansible-tmp-1468943476.88-266972946311694 `" ) &&
sleep 0'"'"''
<host1.example.com> PUT /tmp/tmpO6LVmh TO
/root/.ansible/tmp/ansible-tmp-1468943476.87-148558126071189/ping
<host1.example.com> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[host1.example.com]'
<host2.example.com> PUT /tmp/tmpPCIRrD TO
/root/.ansible/tmp/ansible-tmp-1468943476.87-38319674786550/ping
<host2.example.com> SSH: EXEC sftp -b - -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r '[host2.example.com]'
<host-test.example.com> PUT /tmp/tmp2vmkei TO
/root/.ansible/tmp/ansible-tmp-1468943476.88-266972946311694/ping
<host-test.example.com> SSH: EXEC sftp -b - -C -vvv -o
ControlMaster=auto -o ControlPersist=60s -o
KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r
'[host-test.example.com]'
host1.example.com | UNREACHABLE! => {
"changed": false,
"msg": "SSH Error: data could not be sent to the remote host. Make
sure this host can be reached over ssh",
"unreachable": true
}
<host2.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<host2.example.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt host2.example.com
'/bin/sh -c '"'"'LANG=de_DE.UTF-8 LC_ALL=de_DE.UTF-8
LC_MESSAGES=de_DE.UTF-8 /usr/bin/python
/root/.ansible/tmp/ansible-tmp-1468943476.87-38319674786550/ping; rm -rf
"/root/.ansible/tmp/ansible-tmp-1468943476.87-38319674786550/" >
/dev/null 2>&1 && sleep 0'"'"''
<host-test.example.com> ESTABLISH SSH CONNECTION FOR USER: None
<host-test.example.com> SSH: EXEC ssh -C -vvv -o ControlMaster=auto -o
ControlPersist=60s -o KbdInteractiveAuthentication=no -o
PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey -o
PasswordAuthentication=no -o ConnectTimeout=10 -o
ControlPath=/root/.ansible/cp/ansible-ssh-%h-%p-%r -tt
host-test.example.com '/bin/sh -c '"'"'LANG=de_DE.UTF-8
LC_ALL=de_DE.UTF-8 LC_MESSAGES=de_DE.UTF-8 /usr/bin/python
/root/.ansible/tmp/ansible-tmp-1468943476.88-266972946311694/ping; rm
-rf "/root/.ansible/tmp/ansible-tmp-1468943476.88-266972946311694/" >
/dev/null 2>&1 && sleep 0'"'"''
host2.example.com | SUCCESS => {
"changed": false,
"invocation": {
"module_args": {
"data": null
},
"module_name": "ping"
},
"ping": "pong"
}
host-test.example.com | SUCCESS => {
"changed": false,
"invocation": {
"module_args": {
"data": null
},
"module_name": "ping"
},
"ping": "pong"
}
[2016.07.19 17:51:17] ~/ansible
I'm somewhat curious about the following line:
ESTABLISH SSH CONNECTION FOR USER: None
I would expect ansible to establish a connection for root. Shouldn't
that be the default behaviour?