-u not being set when running ad-hoc ansible run?

252 views
Skip to first unread message

John Miller

unread,
Mar 2, 2020, 7:24:46 PM3/2/20
to Ansible Project
Hello everyone,

I'm trying to run the following ad hoc ansible command to run the date command remotely against an IP camera running Linux:
myuser@myhost:$ ansible camera.site.example.org -i /path/to/inventory -u root -k -m raw -a date

and receiving the following error:
camera.site.example.org | UNREACHABLE! => {
   
"changed": false,
   
"msg": "Invalid/incorrect password: Permission denied, please try again.",
   
"unreachable": true
}

Running with -vvv seems to suggest that the -u root option is not being applied:
myuser@myhost:$ ansible -vvv camera.site.example.org -i /path/to/inventory -u root -k -m raw -a date
ansible
2.9.3
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = [u'/home/myuser/.ansible/plugins/modules', u'/usr/share/ansible/plugins/modules']
  ansible python
module location = /usr/lib/python2.7/site-packages/ansible
  executable location
= /usr/bin/ansible
  python version
= 2.7.5 (default, Aug  7 2019, 00:51:29) [GCC 4.8.5 20150623 (Red Hat 4.8.5-39)]
Using /etc/ansible/ansible.cfg as config file
SSH password
:
host_list declined parsing
/path/to/inventory as it did not pass its verify_file() method
script declined parsing
/path/to/inventory as it did not pass its verify_file() method
auto declined parsing /path/to/inventory as it did not pass its verify_file() method
Parsed /path/to/inventory inventory source with ini plugin
META
: ran handlers
<camera.site.example.org> ESTABLISH SSH CONNECTION FOR USER: myuser
<camera.site.example.org> SSH: EXEC sshpass -d8 ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="myuser"' -o ConnectTimeout=10 -o ControlPath=/home/myuser/.ansible/cp/22d4672695 -tt camera.site.example.org date
<camera.site.example.org> (5, '', 'Permission denied, please try again.\r\n')
camera
.site.example.org | UNREACHABLE! => {
   
"changed": false,
   
"msg": "Invalid/incorrect password: Permission denied, please try again.",
   
"unreachable": true
}

If I run the ssh command listed outside of ansible, substituting "root" for "myuser", things work fine:
myuser@myhost:$ ssh -C -o ControlMaster=auto -o ControlPersist=60s -o 'User="root"' -o ConnectTimeout=10 -o ControlPath=/home/myuser/.ansible/cp/22d4672695 -tt camera.site.example.org date
root@camera
.site.example.org's password:
Tue Mar  3 00:20:59 GMT 2020
myuser@myhost:$

Any idea why the -u option isn't being passed to the underlying ssh command?

John Miller
Reply all
Reply to author
Forward
0 new messages