Skip to content

Instantly share code, notes, and snippets.

@rektide
Last active July 28, 2016 14:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rektide/6f17061652898fddd57845857c149756 to your computer and use it in GitHub Desktop.
Save rektide/6f17061652898fddd57845857c149756 to your computer and use it in GitHub Desktop.
become changes ansible_ssh_user
---
- hosts: all
tasks:
# this is created with my username in my homedir
- file: path=~/ansible-become-test state=directory owner="{{ansible_ssh_user}}"
# this is owned by root
- file: path=/opt/ansible-become-test state=directory owner="{{ansible_ssh_user}}"
become: True
@rektide
Copy link
Author

rektide commented Jul 28, 2016

ok so ansible_ssh_user is deprecated and not populated. it's ansible_user now. updating the var gives me a /opt/ansible-become-test owned by the ansible user, yay.

@rektide
Copy link
Author

rektide commented Jul 28, 2016

ansible_user is also not populated. ansible_env.USER was suggested by @agaffney. i'm not sure what populated ansible_user_id but it appears to have the value i want in the very limited set of conditions i've tried.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment