user: root ignored when running on hosts:localhost ?

54 views
Skip to first unread message

Torsten Reinhard

unread,
May 21, 2015, 10:34:35 AM5/21/15
to ansible...@googlegroups.com
Hi,

I´m using Ansible 1.8.2 running on Virtualbox (CentOs6.5) with this small playbook:

- name: Test playbook for roles/jdk
  hosts
: localhost
  user
: root
 
  vars
:
    jdk_root
: /tmp/opt/java
   
  roles
:
   
- { role: jdk, jdk_version: "1.8.0_40" }


The role looks like:

---
#
# JDK
#
 
- debug: var=ansible_user_id
       
 
- name: Assures {{jdk_root}} dir exists
    file
: path={{jdk_root}} state=directory  
...



When I run this playbook using the command:

ansible-playbook -i /path/to/hosts test-jdk.yml -v

I receive the following output:

PLAY [Test playbook for roles/jdk] ********************************************

GATHERING FACTS
***************************************************************
ok
: [localhost]

TASK
: [jdk | debug var=ansible_user_id] ***************************************
ok
: [localhost] => {
   
"ansible_user_id": "vagrant"
}
...


=> Why is the User "vagrant" used here, although I set user: root in the playbook ?

A task that tries to chown fails afterwards.

Whenever I define a [group_name] in my hosts file configured to localhost (192.168.....) it all works fine.


Thanx for any explanation,

Torsten
sdfs

ssdf

Brian Coca

unread,
May 21, 2015, 12:59:37 PM5/21/15
to ansible...@googlegroups.com
remote_user( which is what the deprecated 'user' sets) is ignored on
connection: local as there is no 'remote login', you can either force
to ssh to localhost as root with connection: ssh or you can use
become: true to use sudo to become root locally.
> --
> 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/1a5187cb-2c29-4fbb-b013-aead2734b767%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



--
Brian Coca
Reply all
Reply to author
Forward
0 new messages