Hello there !
I have few questions about virtualenv with AWX:
-
How many virtualenv can we create in AWX node ?
-
Is it possible to run classic Ansible and Virtualenv in parallel ?
-
If yes, How ? In my case, I was able to run a playbook in just one environment (classic ansible or in virtualenv that I created).
I have proceeded as following:
In order to run a playbook through my virtualenv (test_venv), I edited inside Awx_task, the file /etc/ansible/ansible.cfg and pointed out my module path with library= /var/lib/awx/venv/test_venv/lib/python2.7/site-packages/ansible/.
While on the other hand, to run a playbook in classic ansible , i commented out the line library= /var/lib/awx/venv/test_venv/lib/python2.7/site-packages/ansible/
I need to know, Is it possible to run at least two playbooks in both environment (ansible classic and virtualenv) at the same time?
Thanks for your response
Hello!
awx has support for custom virtualenvs which should solve most of the issues you’re running into. Take a look at the details in this document:
https://github.com/ansible/awx/blob/devel/docs/custom_virtualenvs.md
Hello Ryan,
Thanks for the document, it’s very interesting but it doesn’t explain how to run different custom virtualenvs in parallel.
Let’s me explain myself, I want to give for example three persons (X,Y and Z) to run their playbooks concurrently through AWX platform.
X runs his playbook while using the default ansible.
Y runs his playbook while using custom-venv-Y.
Z runs his playbook while using custom-venv-Z.
Is it possible to run these playbooks concurrently without editing /etc/ansible/ansible.cfg or activate/deactivate venv in each launch of playbook ?
Of course you could. You can point your custom virtual environment in job template as well as inside organization.
If X , Y & Z are on different teams then point the ansible custom virtual environment to the respective version inside organization .
If X, Y & Z are on same team then create 3 job template then point each job template ansible environment to custom virtual environment and make sure to mark “enable concurrent jobs” . If you don’t want 3 job templates, then create one and make the necessary edit while executing jobs
Hope it helps .
Hello Sujith,
It’s m
Of course you could. You can point your custom virtual environment in job template as well as inside organization.
If X , Y & Z are on different teams then point the ansible custom virtual environment to the respective version inside organization .
Yes, I did it
If X, Y & Z are on same team then create 3 job template then point each job template ansible environment to custom virtual environment and make sure to mark
here the problem!!!
Because when every of them create their job template and assign it to their custom venv, they won’t able to run their playbook at the same time since the file /etc/ansible/ansible.cfg is common for them.
For instance,
-
X creates his template and assign it to custom venv named custom_venv_X
So if he want to run the playbook, He must edit the file /etc/ansible/ansible.cfg inside awx_task container by setting the library line with for example
library = /var/lib/awx/venv/custom_venv_X/lib/python2.7/site-packages/ansible
-
Y creates his job template and assign it to custom venv named custom_venv_Y
If he want to run his job template, he will edit the same /etc/ansible/ansible.cfg file used by X, so he’ll change the library line for example
library = /var/lib/awx/venv/custom_venv_Y/lib/python2.7/site-packages/ansible
Indeed after ansible.cfg being changed by Y, if X run at this time his playbook, it will fail.
It’s the fact, AWX doesn’t allow to run multiple job templates with different custom virtual environments at the same time.
note : I tried to set path modules like that
library = /var/lib/awx/venv/custom_venv_X/lib/python2.7/site-packages/ansible, /var/lib/awx/venv/custom_venv_Y/lib/python2.7/site-packages/ansible
And after running job templates of X and Y.
Result : only job template of Y succeed.
So If you know other method, please let me know.
Thanks in advance
I find a solution which not very sexy but it works.
I pushed all my custom modules inside /var/lib/awx/venv/modules/ and pointed it in ansible.cfg file
library = /var/lib/awx/venv/modules/
Now, I can run successfully the job templates (X,Y and Z) in same time.
Thanks for your response
Use ansible.cfg in your project directory instead,assuming that you have different projects using the different virtual environments (if you don’t, you’ll likely have other issues anyway)