# Current practice for setting ansible\_python\_interpreter based on group\_by: key={{ansible\_distribution}}

**URL:** <https://forum.ansible.com/t/current-practice-for-setting-ansible-python-interpreter-based-on-group-by-key-ansible-distribution/26073>\
**Category:** Ansible Project\
**Created:** [November 19, 2017, 10:57pm UTC](https://forum.ansible.com/t/current-practice-for-setting-ansible-python-interpreter-based-on-group-by-key-ansible-distribution/26073 "2017-11-19T22:57:56Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Darren\_S](https://avatars.discourse-cdn.com/v4/letter/d/59ef9b/32.png) [@Darren\_S](https://forum.ansible.com/u/Darren_S)\
**Post date:** [November 19, 2017, 10:57pm UTC](https://forum.ansible.com/t/current-practice-for-setting-ansible-python-interpreter-based-on-group-by-key-ansible-distribution/26073/1 "2017-11-19T22:57:56Z")

</div>

ansible 2.3.1.0  
python 2.7.14

I'm just wondering the best approach to handling a multi-OS  
environment where python interpreters are located at different paths:

Linux:  
&nbsp;&nbsp;/usr/bin/python

OpenBSD, FreeBSD  
&nbsp;&nbsp;/usr/local/bin/python

macOS w/Homebrew  
&nbsp;&nbsp;/usr/local/bin/python2

...and ansible\_python\_interpreter needs to be overridden on a large  
part of the environment.

In this deployment I strongly want to use the approach like in [1] to  
group hosts by OS using ansible\_distribution fact, so I want to avoid  
static declarations in inventory files and would like this to be able  
to be specified in something like group\_vars/Linux,  
group\_vars/OpenBSD, etc. leveraging ansible\_distribution groupings.

Is there a way to achieve this? Or is it a chicken and egg problem  
that requires inventory specifications because the  
ansible\_distribution cannot be known prior to invoking Python?

[1] [https://github.com/ansible/ansible-examples/blob/master/language\_features/group\_by.yml](https://github.com/ansible/ansible-examples/blob/master/language_features/group_by.yml)
