Problems running playbook as root when ansible_ssh_user specified

127 views
Skip to first unread message

Humberto Camacho

unread,
May 28, 2014, 3:54:23 PM5/28/14
to ansible...@googlegroups.com
Hello,

I have been searching a couple of days off and on. 

I am using ansible 1.7 and in the process of creating a playbook to check the kernel version and if it is lower than X check if python-simplejson is installed. If it is not then install the package.

Below is a sample of my simple playbook.


---
- hosts: test

  gather_facts
: false

  tasks
:
   
- name: Querying Kernel Version
      raw
: uname -r
     
register: kernel_version
      ignore_errors
: True


   
#- name: Check/Install if python-simplejson is installed (Old Kernels)
   
- raw: yum -qy install python-simplejson
     
#raw: rpm -q python-simplejson
     
when: kernel_version.stdout.find("2.6.18") != -1
     
register: rpm_check
      ignore_errors
: True
       



Sample of my host file. 

[test]
ClientA           ansible_ssh_port=2209     ansible_ssh_host=192.168.1.12      ansible_ssh_user=userA
ClientB           ansible_ssh_port=20243   ansible_ssh_host=192.168.1.11      ansible_ssh_user=userB



When i run the playbook with the following command.

ansible-playbook common/os_check.yml --su-user=root --ask-su-pass -vvvv
or
ansible-playbook common/os_check.yml -R --step -vvvv

I get the following ERROR. I noticed that it never passes the root user.....

PLAY [test] *******************************************************************


TASK
: [Querying Kernel Version] ***********************************************
<192.168.1.12> ESTABLISH CONNECTION FOR USER: userA on PORT 2209 TO 192.168.1.12
<192.168.1.11> ESTABLISH CONNECTION FOR USER: userB on PORT 20243 TO 192.168.1.11
<192.168.1.11> EXEC uname -r
ok
: [ClientB] => {"rc": 0, "stderr": "", "stdout": "2.6.32-279.el6.x86_64\n"}
fatal
: [192.168.1.12] => {'msg': 'FAILED: Authentication failed.', 'failed': True}


TASK
: [raw yum -qy install python-simplejson] *********************************
skipping
: [ClientB]


PLAY RECAP
********************************************************************
           to
retry, use: --limit @/home/userA/os_check.retry


ClientB                    : ok=1    changed=0    unreachable=0    failed=0  
ClientA                    : ok=0    changed=0    unreachable=1    failed=0  



I would think it would run as the user i told it to run as. It seems that the hosts file overrides whatever parameter i give it....I might be thinking of this wrong...

thanks for your help!




James Cammarata

unread,
May 29, 2014, 10:17:16 AM5/29/14
to ansible...@googlegroups.com
It appears from that output that your userB is failing to login at all to that system, so it's never getting to the su step (which occurs after login). I would check your /var/log/secure or /var/log/auth.log (depending on your distro) to see what the error may be.


--
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/c21aa37d-6929-4bd8-a6bf-7467c5695390%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages