Skip to content

Instantly share code, notes, and snippets.

@ekollof
Created July 28, 2016 11:29
Show Gist options
  • Save ekollof/6590f4ae02ac56225c164d3eb5518772 to your computer and use it in GitHub Desktop.
Save ekollof/6590f4ae02ac56225c164d3eb5518772 to your computer and use it in GitHub Desktop.
Find python interpreter and use it (useful when mixing Linux/BSD/Solaris/etc hosts)
- hosts: all
gather_facts: false
tasks:
- raw: which {{item}}
register: mypython
ignore_errors: True
with_items:
- python
- python2
- python2.7
- python27
- python2.6
- python26
- set_fact: ansible_python_interpreter={{(mypython.results|rejectattr('rc')|list|first).stdout.strip()|default(omit)}}
- debug: var=ansible_python_interpreter
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment