Availability of python update package for Ansible pip update during development

I am writing some Ansible plays for setting up virtual virtual python, and also during development to update the python package and restart the server. I am having problems getting a service pack package. I don’t care how it is done, but during development I would prefer to just add the path to the python path in virtualenv and then just restart the server, but I still do not understand how to do this in Ansible.

So my question is how to configure the local git repository, which is either installed in the packages of the virtualenv site or configures Ansible for sys.path. Includes the repo location using the correct virtualenv.

Currently, I tried:

sudo pip install ~/workspace/python-repo 

Before installing the package, I renamed the class that I have from Authenticator to something completely wrong, like Authen. The class shows Authen during a new installation. Then I change the class name to the correct name (Authenticator), downgrade and run

 sudo pip install ~/workspace/python-repo --upgrade 

but after checking the actual file in the site packages, it still shows the name Authen, not the updated file.

How can I do this to use a local repo during development and get instant updated files in my environment? And also make it a repeatable process through Ansible.

Here is what I am trying to do in Ansible. My first game is setting up an environment that I want to run only once.

 - name: Install python-repo local_action: pip name=${python_root} virtualenv=${working_dir}/development 

$ {python_root} is just the place for my python project, and of course the working directory is the new virtualenv setting.

Then somehow I want the development game to update the python repository in virtualenv. This is what I have, but it 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} 
+6
source share
1 answer

I am going to post this as the correct answer for everyone else to return to this question.

I currently have an Ansible game that sets up the environment by installing local python packages and then creating a virtual virtual machine and installing everything in it for development. First, when setting up virtualenv and installing the local git repository in the environment, I use these tasks in Ansible.

 - name: Source virtualenvwrapper. local_action: shell /usr/local/bin/virtualenvwrapper.sh executable=/bin/bash - name: Set Enviroment to working directory. local_action: shell export WORKON_HOME=${working_dir} - name: Set pip to use working virtual enviroment. local_action: shell export PIP_VIRTUALENV_BASE=$WORKON_HOME - name: Create new virtualenv in development. local_action: pip requirements=${virtual_requirements} virtualenv=${working_dir}/development - name: Install python-repo as editable local_action: pip name=${python_root} virtualenv=${working_dir}/development extra_args='-e ${python_root}' 

Now I'm starting to evolve, and when I'm ready to test things and run them, I use another Ansible game to deploy local changes. I use these tasks.

 - name: Update python-repo local_action: pip name=${python_root} virtualenv=${working_dir}/development extra_args='--upgrade' - name: Restart services. local_action: service name=${item} state=restarted with_items: ${services} 

This instantly accepts my python updates and restarts my server. I have been banging my head about this for a long time from the php development environment and I only had to press F5 to accept the changes. I need a good python development environment and I think this is an acceptable process.

+11
source

Source: https://habr.com/ru/post/953710/


All Articles