Minimal Python need for the "agent"

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

Hi Ronaldo, this is covered in the “Managed Node Requirements” section of our documentation: 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!

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

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

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.

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.

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

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

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.

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