Having Ansible pip update python package during development
I have been writing some Ansible plays to setup a python virtualenv and
also during development to update the python package and restart the
server. I am having problems though getting pip to update a package. I
don't really care how this is done, but I would prefer during development
just adding the path to the python path in the virtualenv and then just
restarting the server, but I haven't figured out how to do that in Ansible
yet.
So my question is how can I setup a local git repo that either installs
into site-packages of the virtualenv or setup Ansible to sys.path.insert
the location of the repo using the correct virtualenv.
Currently I was trying to do:
sudo pip install ~/workspace/python-repo
Before I install the package I renamed a class that I have from
Authenticator to something completely wrong like Authen. The class shows
Authen during a fresh install. Then I change the class name back to the
correct name (Authenticator), bump the version and run
sudo pip install ~/workspace/python-repo --upgrade
but after inspecting the actual file in site-packages it still shows the
Authen name rather than the updated file.
How can I make this so that I use a local repo during development and get
instant updated files in my environment? As well as making this a
repeatable process through Ansible.
Here is what I am trying to do in Ansible. My first play is setting up the
environment which I only want to run 1 time.
- name: Install python-repo
local_action: pip name=${python_root}
virtualenv=${working_dir}/development
${python_root} is only the location to my python project and of course the
working directory is the new virtualenv setup.
Then somehow I want a development play to update the python repo in the
virtualenv. This is what I have so far but this doesn't work either.
- name: Update python-repo
local_action: pip name=${python_root}
virtualenv=${working_dir}/development
state=latest
- name: Restart services.
local_action: service name=${item} state=restarted
with_items: ${services}
No comments:
Post a Comment