# ansible\_python\_interpreter for ad-hoc ansible commands

**URL:** <https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338>\
**Category:** Ansible Project\
**Created:** [January 14, 2014, 12:53pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338 "2014-01-14T12:53:17Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [January 14, 2014, 12:53pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338/1 "2014-01-14T12:53:17Z")

</div>

Hi,

What would be the best way to set ansible\_python\_interpreter for almost 50% of the hosts in the inventory for ad-hoc ansible command. what i did is i grouped them under one group in the inventory [python27:children] and have set the vars for this group [python27:vars]  
ansible\_python\_interprete=/path/to/python27/bin/python27

it is working, however i am not sure if that is the best way to do it, how would you do it?

kind regards

Walid

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 14, 2014, 1:26pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338/2 "2014-01-14T13:26:32Z")

</div>

This would be a fine way to do it.

I’d probably just associate it with a group named after the OS if that were me, but maybe it’s not OS specific in your case.

---

<div class="post-metadata">

**Author:** ![Walid](https://avatars.discourse-cdn.com/v4/letter/w/ea5d25/32.png) [@Walid](https://forum.ansible.com/u/Walid)\
**Post date:** [January 14, 2014, 1:30pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338/3 "2014-01-14T13:30:32Z")

</div>

Hi Michael,

that is what i have done eventually, created a group for RHEL5 and add the possible groups that use rhel5 under it to get the variable.

thanks,

W.

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan2](https://avatars.discourse-cdn.com/v4/letter/m/da6949/32.png) [@Michael\_DeHaan2](https://forum.ansible.com/u/Michael_DeHaan2)\
**Post date:** [January 14, 2014, 1:32pm UTC](https://forum.ansible.com/t/ansible-python-interpreter-for-ad-hoc-ansible-commands/14338/4 "2014-01-14T13:32:03Z")

</div>

For information of other users, RHEL 5 should be fine if you just install python-simplejson for usage of most modules.

However if you have python27 installed that’s good too 🙂
