assuming we are using $HOME/src
as source code directory and $HOME/bin
is in PATH
so we can add script more easily.
get ansible source code first.
$ cd $HOME/src
$ git clone https://github.com/ansible/ansible
we need to do some hacking to hacking/env-setup
script coming with ansible source code.
$ cd $HOME/bin
$ cp $HOME/src/ansible/hacking/env-setup _asb # say we use this to dispatch command
open _asb
with your favorite editor, rewrite some code
HACKING_DIR
HACKING_DIR="$HOME/src/ansible/hacking"
- append these lines (say we've created a virtualenv there)
bin=$1
shift
$HOME/src/ansible/.virtualenv/bin/python $HOME/src/ansible/bin/$bin $@
# you could change above command to this, if you prefer pyenv
$HOME/.pyenv/versions/2.7.5/bin/python $HOME/src/ansible/bin/$bin $@
- write the command we will use,
$HOME/bin/ansible
#!/bin/bash
bin="${0##/*/}"
/bin/bash $HOME/bin/_asb $bin $@
so as the $HOME/ansible-playbook
, but this time, we just need symlinking :D
$ ln -s $HOME/bin/ansible $HOME/bin/ansible-playbook
ansible's using distribute
by default
# in setup.py
# ...
from distribute.core import setup
# ...
This just sucks! python setup.py develop
reports no such command! python setup.py install
reports unknown option install_requires
(How do they even install this python package!?!?).
change setup line in setup.py
# comment out this line
from distribute.core import setup
# use this, and off course you should have setuptools installed =D
from setuptools import setup
then run
.virtualenv/bin/python setup.py develop
try
$ ansible
嗯,这个不错。可以不需要copy env-setup,新建一个
_asb
文件只要这几行就好了