Skip to content

Instantly share code, notes, and snippets.

@ekollof
Created July 28, 2016 11:29
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 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