Skip to content

Instantly share code, notes, and snippets.

@kskmori
Created August 26, 2019 06:45
Show Gist options
  • Save kskmori/08db4ddf511ed08fecff722eb60114d7 to your computer and use it in GitHub Desktop.
Save kskmori/08db4ddf511ed08fecff722eb60114d7 to your computer and use it in GitHub Desktop.
osc2018tk-demo sudo install debug.yml
- hosts: 127.0.0.1
connection: local
become: true
max_fail_percentage: 0
tasks:
- name: debug
debug:
var: ansible_facts
- name: user
debug:
var: ansible_env.SUDO_USER
- name: home
debug:
var: ansible_env.HOME
@kskmori
Copy link
Author

kskmori commented Aug 26, 2019

Summary: sudo vs. -K as ansible-playbook local privilege escalation methods

  • sudo ansible-playbook
    • HOME is different between Linux and OSX
      • Linux: root's home
      • OSX: regular user's home - this is OSX's default
  • ansible-playbook -K
    • HOME is different from the default sudo behavior on OSX, but behaves similar to Linux
    • SUDO Password is always asked even if already in root
    • SUDO_USER env var is not set if already in root

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