Skip to content

Instantly share code, notes, and snippets.

@hyperized
Created March 16, 2016 08:51
Show Gist options
  • Save hyperized/de9f5498af9d967bf360 to your computer and use it in GitHub Desktop.
Save hyperized/de9f5498af9d967bf360 to your computer and use it in GitHub Desktop.
[09:50] myuser@machine:~/$ cat test.yml
---
- hosts: localhost
gather_facts: true
become: true
tasks:
- set_fact:
my_user: myuser
- debug: msg="{{ lookup('pipe', 'id -u ' + my_user) }}"
[09:50] myuser@machine:~/$ ansible-playbook test.yml
SUDO password:
PLAY ***************************************************************************
TASK [setup] *******************************************************************
ok: [localhost]
TASK [set_fact] ****************************************************************
ok: [localhost]
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "5670"
}
PLAY RECAP *********************************************************************
localhost : ok=3 changed=0 unreachable=0 failed=0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment