ssh difference between ansible ad-hoc and ansible-playbook for localhost

458 views
Skip to first unread message

Anthony Cheng

unread,
Jul 7, 2016, 3:03:48 PM7/7/16
to Ansible Project
I noticed in troubleshooting SSH authentication that there is a difference between ansible ad-hoc and ansible-playbook in terms of SSH for localhost.

Specifically, I was able to get a playbook targeted at localhost to work but not ansible ad-hoc command targeted at localhost.

Anthony Cheng

unread,
Jul 7, 2016, 3:08:02 PM7/7/16
to Ansible Project
To be more specific, ad-hoc command checks in ~/.ssh/authorized key whereas playbook does not.  I didn't specific any user in the playbook whereas I try to run as root/ubuntu/none with ad-hoc (-u).

Dick Davies

unread,
Jul 7, 2016, 3:38:05 PM7/7/16
to ansible list
That sounds really - odd.

It sounds silly, but are you _sure_ ansible and ansible-playbook are
at the same version?

ansible --version
ansible-playbook --version

Maybe there's some symlink spaghetti going on or something??

If not, that sounds like a bug, I'd file an issue.
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/98c0c14f-549c-4f76-9475-ee0c5ef71406%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.

Anthony Cheng

unread,
Jul 7, 2016, 4:56:17 PM7/7/16
to Ansible Project, di...@hellooperator.net
Apparently ansible-playbook is a symlink on this system; I had /usr/bin/ansible owned by the group ansible before but I changed it back to root for testing & got so result.  What is more weird is that if ansible-playbook is just a symlink why is the behavior different?

root@ip-172-17-0-237:/etc/ansible# ansible --version
ansible
2.1.0.0
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = Default w/o overrides

root@ip
-172-17-0-237:/etc/ansible# ansible-playbook --version
ansible
-playbook 2.1.0.0
  config file
= /etc/ansible/ansible.cfg
  configured
module search path = Default w/o overrides


root@ip
-172-17-0-237:/etc/ansible# ll /usr/bin/ansible
-rwxr-xr-x 1 root ansible 4201 May 25 13:03 /usr/bin/ansible*

root@ip
-172-17-0-237:/etc/ansible# ll /usr/bin/ansible-playbook
lrwxrwxrwx
1 root root 7 May 25 13:03 /usr/bin/ansible-playbook -> ansible*

I checked on another older version and ansible-playbook is a script:

 
antho@stratus ~/.ssh  which ansible
/
usr/bin/ansible
 antho@stratus
~/.ssh  which ansible-playbook
/
usr/bin/ansible-playbook
 antho@stratus
~/.ssh  ll /usr/bin/ansible-playbook
-rwxr-xr-x+ 1 antho antho 3.9K May 22 23:18 /usr/bin/ansible-playbook
 antho@stratus
~/.ssh  ansible --version
ansible 2.0.2.0
  config file = /
etc/ansible/ansible.cfg
  configured
module search path = Default w/o overrides
 antho@stratus
~/.ssh  ansible-playbook --version
ansible-playbook 2.0.2.0
  config file = /
etc/ansible/ansible.cfg
  configured
module search path = Default w/o overrides

btw here's the playbook i used for testing; nothing fancy:

ot@ip-172-17-0-237:/etc/ansible# cat testing/test_var.yml
---
- hosts: localhost
  gather_facts
: no

  vars
:
     user
: "{{ lookup('file', '/etc/ansible/testing/vars.yml') }}"

  tasks
:

     
- debug: msg="the value of foo.txt is {{ user }}"
Reply all
Reply to author
Forward
0 new messages