ansible_user_id always root

264 views
Skip to first unread message

greg.h...@gmail.com

unread,
Aug 15, 2015, 12:59:08 PM8/15/15
to battleschool
I am trying to use {{ansible_user_id}} to get the user_id of the user running the playbook. I can not get it to return a value other than root. I also tried running battle without sudo and I receive this error:

Task FAILED: setup [sudo via ansible, key=jkwrmhyzyzgywfccxtrkmxesrzjxlahj] password:

Task NO HOSTS: debug
to retry, use: --limit @/Users/ghengeli/test.retry

Playbook FAILED, ok=0, changed=0, unreachable=0, failed=1

My sample config file is:

---
sources:
local:
- test.yml

And my test playbook is simply:

- hosts: workstation

tasks:
- name: print from playbook
sudo: no
debug: msg="in playbooks {{ansible_user_id}}"


d.wilm...@googlemail.com

unread,
Oct 1, 2015, 4:37:01 AM10/1/15
to battleschool, greg.h...@gmail.com
I have the same problem here.
Is this a bug? Or is this intended behavior?

Borys Borysenko

unread,
Oct 10, 2015, 4:03:17 AM10/10/15
to battleschool, greg.h...@gmail.com, d.wilm...@googlemail.com
Same issue for me

➜  ~  cat ~/.battleschool/config.yml
---
cache_dir: ~/.battleschool/cache

sources:
  local:
    - playbook.yml
➜  ~  cat ~/.battleschool/playbooks/playbook.yml
---
- hosts: workstation

  tasks:
    - name: print from playbook
      debug: msg="in playbooks/playbook.yml"
➜  ~  battle
## Updating sources ##############################################################################################
## Executing playbook /Users/bbo/.battleschool/playbooks/playbook.yml ############################################
Task FAILED: setup [sudo via ansible, key=hanyvnntrcdqacckwhqemsutckjxuvyg] password:

Task NO HOSTS: debug
           to retry, use: --limit @/Users/bbo/playbook.retry

Playbook FAILED, ok=0, changed=0, unreachable=0, failed=1

public...@gmail.com

unread,
Nov 5, 2015, 11:31:02 AM11/5/15
to battleschool, greg.h...@gmail.com
Well, the same problem for me.

Is the project alive ?

Andrey


public...@gmail.com

unread,
Nov 5, 2015, 12:17:34 PM11/5/15
to battleschool, greg.h...@gmail.com
I have found the solution.
If I specify the SUDO password it works:

battle --ask-sudo-pass

SUDO password:
## Updating sources #######################################################################
Task OK: git
Task OK: setup
Task OK: apt
Playbook OK, ok=2, changed=1, unreachable=0, failed=0
## Battleschool completed #######################################################################

Cheers,
Andrey

Spencer Gibb

unread,
Nov 5, 2015, 1:01:43 PM11/5/15
to battleschool
That is how I run by default.

--
Spencer Gibb
spe...@gibb.us


--
You received this message because you are subscribed to the Google Groups "battleschool" group.
To unsubscribe from this group and stop receiving emails from it, send an email to battle-schoo...@googlegroups.com.
To post to this group, send email to battle...@googlegroups.com.
Visit this group at http://groups.google.com/group/battle-school.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages