Hi,
Perhaps I overlooked something obvious, but it seemed to me that creating a blank virtualenv and running ‘python setup.py install’ from a checkout wasn’t sufficient to install ansible, nor if I manually install the dependencies. I saw Chris Read looked into installing an OSX development environment before (though I’m looking into this not just for OSX development; I want to deploy on Heroku, and anything not pip-installable using requirements.txt would be really a pain to use), but couldn’t find his results.
Any tips?
Cheers,
You didn't say what actually happened so all I can do is guess -- I suspect you'll need to manually install the modules and use --module-path, since they aren't being found in the default path location.
--Michael
Sorry, I didn’t think there’s output to be provided because the docs made it seem like this feature isn’t supported at all.
Anyhow, here’s what happens on my box (Python is pretty much what comes with vanilla OSX 10.7.4):
$ cd /tmp
$ virtualenv ansible
cd New python executable in ansible/bin/python
Installing setuptools…anb…done.
Installing pip…i…done.
$ cd ansible
$ source bin/activate
(ansible)$ git clone git://github.com/ansible/ansible.git
Cloning into ‘ansible’…
remote: Counting objects: 4816, done.
remote: Compressing objects: 100% (1573/1573), done.
remote: Total 4816 (delta 2829), reused 4665 (delta 2701)
Receiving objects: 100% (4816/4816), 788.14 KiB | 393 KiB/s, done.
Resolving deltas: 100% (2829/2829), done.
(ansible)$ cd ansible/
(ansible)$ python setup.py install
/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/distutils/dist.py:267: UserWarning: Unknown distribution option: ‘install_requires’
warnings.warn(msg)
running install
running build
running build_py
creating build
creating build/lib
creating build/lib/ansible
copying lib/ansible/init.py → build/lib/ansible
copying lib/ansible/callbacks.py → build/lib/ansible
copying lib/ansible/constants.py → build/lib/ansible
copying lib/ansible/errors.py → build/lib/ansible
copying lib/ansible/utils.py → build/lib/ansible
running build_scripts
creating build/scripts-2.7
copying and adjusting bin/ansible → build/scripts-2.7
copying and adjusting bin/ansible-playbook → build/scripts-2.7
changing mode of build/scripts-2.7/ansible from 644 to 755
changing mode of build/scripts-2.7/ansible-playbook from 644 to 755
running install_lib
creating /private/tmp/ansible/lib/python2.7/site-packages/ansible
copying build/lib/ansible/init.py → /private/tmp/ansible/lib/python2.7/site-packages/ansible
copying build/lib/ansible/callbacks.py → /private/tmp/ansible/lib/python2.7/site-packages/ansible
copying build/lib/ansible/constants.py → /private/tmp/ansible/lib/python2.7/site-packages/ansible
copying build/lib/ansible/errors.py → /private/tmp/ansible/lib/python2.7/site-packages/ansible
copying build/lib/ansible/utils.py → /private/tmp/ansible/lib/python2.7/site-packages/ansible
byte-compiling /private/tmp/ansible/lib/python2.7/site-packages/ansible/init.py to init.pyc
byte-compiling /private/tmp/ansible/lib/python2.7/site-packages/ansible/callbacks.py to callbacks.pyc
byte-compiling /private/tmp/ansible/lib/python2.7/site-packages/ansible/constants.py to constants.pyc
byte-compiling /private/tmp/ansible/lib/python2.7/site-packages/ansible/errors.py to errors.pyc
byte-compiling /private/tmp/ansible/lib/python2.7/site-packages/ansible/utils.py to utils.pyc
running install_scripts
copying build/scripts-2.7/ansible → /private/tmp/ansible/bin
copying build/scripts-2.7/ansible-playbook → /private/tmp/ansible/bin
changing mode of /private/tmp/ansible/bin/ansible to 755
changing mode of /private/tmp/ansible/bin/ansible-playbook to 755
running install_egg_info
Writing /private/tmp/ansible/lib/python2.7/site-packages/ansible-0.5-py2.7.egg-info
(ansible)$ ansible
Traceback (most recent call last):
File “/private/tmp/ansible/bin/ansible”, line 25, in
from ansible.runner import Runner
ImportError: No module named runner
(ansible)$
I marked in bold a warning which I received and I saw the comment in setup.py itself saying the library dir isn’t copied over.
I’m pretty sure with some mucking about I could copy, move and symlink things to make ansible work, but the question is whether or not I’m supposed to be able to make it completely automatically installable.
If it isn’t, and considering this rejected pull request, would you be interested in a patch that would make it completely ‘python setup.py install’-able? (without version pinning, but with copying the library dir to somewhere thus that make install won’t be necessary)
Thanks,
Do they seem to? They shouldn’t.
We don’t have any modules for managing OS X yet, but it should run reasonably well on OS X control machines.
I think the target should be getting “make install” to work on OS X, not setup.py install, because we already have the RPM using it the way it is now, and further, it’s more of an application not a library anyway.
Please consider my use case: I have a web application doing video processing. When the application discovers the processing queue gets too long, it uses boto to launch additional EC2 instances and (possibly) ansible to provision them as video encoding workers.
So regardless of invocation mechanism (forking and execing ansible or importing and running code from within, I’d prefer the latter but will settle for the former), I’d like to use ansible as a library, and would ideally want it to be installed as a plain Python library.
Maybe I’m trying to use the wrong tool for the job - I’m still not sure ansible is the right tool for me.
Thanks,
Ansible isn't a python library, it's a systems management application.
The files it uses as modules are executable programs that return JSON,
they are not python modules. The reason for this is the user doesn't
have to write them in Python, they can write them in any language.
I don't see how you can't get the modules onto your EC2 machine as we
have other users doing this.
The main thing that bothered me wasn’t importability, it was easy installation in a contained environment.
I thought the whole idea of ansible was that I don’t need it on my EC2 machines, and that all the work will be done over ssh.
Anyway, maybe it’s just not the right tool for me, I’ll look further.
Thanks!
Correct. I’m not sure what the problem you have with setup.py vs packaging (RPM/Debian/etc) vs make install was then. Can you elaborate?
Modules are transferred over SSH when they are needed. They don’t need to be installed because they are transferred on demand.
–Michael
I have a similar plan for using ansible, and I have working proof-of-concept code already, so I think you’ll be fine. Look inside /bin/ansible for the syntax, you basically create a Runner object with the correct parameters and kick it off, it’s very easy. You just need to set some paths, which can be done using the script /hacking/env-setup in the ansible source.
Like Michael says, SSH is used to transfer over the module and execute it on the remote, returning results as JSON. Pretty effective!