# Minimal Python need for the "agent"

**URL:** <https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873>\
**Category:** Ansible Project\
**Created:** [March 30, 2015, 2:41pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873 "2015-03-30T14:41:38Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ronaldo\_Afonso](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Ronaldo\_Afonso](https://forum.ansible.com/u/Ronaldo_Afonso)\
**Post date:** [March 30, 2015, 2:41pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/1 "2015-03-30T14:41:38Z")

</div>

Hi all,

I’m new to Ansible and I’d like to know what is the really Minimal Python, and modules, needed for the “agent”?

I’m planning on running Ansible against an OpenWRT router that usually has very low flash memory (HD).

Any help would be appreciated.

Thanks …

s  
Ronaldo

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [March 30, 2015, 3:17pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/2 "2015-03-30T15:17:42Z")

</div>

Hi Ronaldo, this is covered in the “Managed Node Requirements” section of our documentation: [http://docs.ansible.com/intro\_installation.html#managed-node-requirements](http://docs.ansible.com/intro_installation.html#managed-node-requirements)

It’s pretty minimal, as long as you’re not executing any modules remotely, which may have additional requirements (ie. ec2 modules), not that I’d expect that in your situation.

Hope that helps!

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [March 30, 2015, 3:20pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/3 "2015-03-30T15:20:56Z")

</div>

The Python-2.4 interpreter is the minimal version of python needed to  
run ansible on the managed nodes (If using python2.4 or 2.5, you also  
need the simplejson module installed). Python-2.6 is needed on the  
controller. You do not need to install ansible or any of its modules  
on the managed node, ansible will copy the ansible modules to the  
node. Some modules may need third party python libraries installed on  
the managed node -- you would need to install those in order for those  
specific ansible modules to work.

If openwrt gives you the option of only installing a portion of the  
python stdlib I'm afraid I don't know which portions you will need and  
which you won't. There are a few that everyone will need (Things to  
handle checksumming and file operations, for instance) but other parts  
of the stdlib can be left out or left out if you turn off some default  
ansible features (like ansible fact checking).

-Toshio

---

<div class="post-metadata">

**Author:** ![Ronaldo\_Afonso](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Ronaldo\_Afonso](https://forum.ansible.com/u/Ronaldo_Afonso)\
**Post date:** [March 31, 2015, 5:36pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/4 "2015-03-31T17:36:18Z")

</div>

Hi James,

Actually I was looking for some answer like:

“What is needed is python 2.7 and modules: locale, encoding, sys, etc …”.

The thing is, I know I can use the “raw” and/or “script” ansible modules with no python as an agente, but I feel like using the whole power of Ansible modues.

I hava a very strict space on flash and I’m not able to put a “minimum python” that can even run an “ansible ping” module.

s  
Ronaldo

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [March 31, 2015, 5:46pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/5 "2015-03-31T17:46:09Z")

</div>

you don't requrie 2.7, you need at most 2.6 for machine from which you  
execute ansible from, 2.4 on target (openwrte) + a json library  
(simplejson). Some modules may have additional requirements.

On my openwrt I have no issues with the existing python, I also don't  
use too many modules on it, mostly template and copy.

---

<div class="post-metadata">

**Author:** ![Ronaldo\_Afonso](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Ronaldo\_Afonso](https://forum.ansible.com/u/Ronaldo_Afonso)\
**Post date:** [April 1, 2015, 2:08pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/6 "2015-04-01T14:08:40Z")

</div>

Hi Brian,

I’m using the latest trunk version of OpenWRT in a 4MBytes flash router.

I installed the python-base package in this router and when I try to run a “ansible ping module” I get a “Could not load locale module”.

I checked the router and the “locale” module was really not installed.

So, at this moment I’m trying to create a OpenWRT python package that includes the python locale module.

p.s) If I had a bigger flash I could put the whole python and use ansible to “provision” my routers.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 1, 2015, 2:44pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/7 "2015-04-01T14:44:17Z")

</div>

That is probably it, i got the 1gb card which gives me a lot of leeway  
to install stuff.

---

<div class="post-metadata">

**Author:** ![Toshio\_Kuratomi](https://avatars.discourse-cdn.com/v4/letter/t/41988e/32.png) [@Toshio\_Kuratomi](https://forum.ansible.com/u/Toshio_Kuratomi)\
**Post date:** [April 1, 2015, 2:45pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/8 "2015-04-01T14:45:19Z")

</div>

Just to be sure, you are running ansible locally (on a laptop or  
desktop with a full python install) and attempting to configure the  
router from there? And your ansible command line is really "ansible  
ROUTER\_NAME -m ping" right?

In OpenWRT's barrier breaker release, they have a minimal python  
package labelled "python-mini" and a complete package called "python"  
You may be able to figure out how to unpack the python opkg and grab  
the modules you need from there. (I haven't looked at the internals of  
opkg, though, so I don't know what format they use).

For a first approximation of the modules you'll need to run any given  
module, grep on the ansible source is probably the best bet. For  
instance for ping:

$ cd /usr/lib/python2.7/site-packages/ansible/  
$ grep import modules/core/system/ping.py  
import exceptions  
from ansible.module\_utils.basic import \*  
# module\_utils.basic is needed by all ansible modules, so you'll need  
the modules it imports as well:  
$ grep import module\_utils/basic.py  
[...]

Anything at the toplevel when you grep is being imported  
unconditionally so you'll definitely need it. imports that are  
indented are either needed only in certain situations (for instance,  
selinux is only needed if you're trying to manage an selinu enabled  
system. So not needed for openwrt) or are alternatives to each other  
(for instance you need either json on simplejson but not both).

-Toshio

---

<div class="post-metadata">

**Author:** ![Ronaldo\_Afonso](https://avatars.discourse-cdn.com/v4/letter/r/aeb1de/32.png) [@Ronaldo\_Afonso](https://forum.ansible.com/u/Ronaldo_Afonso)\
**Post date:** [April 1, 2015, 2:51pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/9 "2015-04-01T14:51:45Z")

</div>

Hi Toshio,

Yes, I’m running ansible from my laptop that is a Debian with a full python 2.7 release.

I’ll take a look at the site-packages/ansible and check if I need to create a OpenWRT python package, probably I’ll need it.

Thanks for your anwser.

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [April 1, 2015, 3:21pm UTC](https://forum.ansible.com/t/minimal-python-need-for-the-agent/17873/10 "2015-04-01T15:21:26Z")

</div>

Keep us posted, this might be a nice thing to add to a FAQ or HowTo.
