How virtualenv works on AWX ?

1,961 views
Skip to first unread message

mamado...@gmail.com

unread,
Jun 14, 2018, 5:19:10 AM6/14/18
to AWX Project
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

Ryan Petrello

unread,
Jun 14, 2018, 2:32:48 PM6/14/18
to AWX Project
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:

mamado...@gmail.com

unread,
Jun 15, 2018, 3:40:58 AM6/15/18
to AWX Project
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 ?

Sujith A R

unread,
Jun 15, 2018, 4:52:04 AM6/15/18
to mamado...@gmail.com, AWX Project
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 .


--
You received this message because you are subscribed to the Google Groups "AWX Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to awx-project...@googlegroups.com.
To post to this group, send email to awx-p...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/awx-project/af15d963-3d68-4327-895b-393655521baf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

mamado...@gmail.com

unread,
Jun 15, 2018, 9:29:03 AM6/15/18
to AWX Project
Hello Sujith,

It's m

Le vendredi 15 juin 2018 10:52:04 UTC+2, Sujith A R a écrit :
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

mamado...@gmail.com

unread,
Jun 15, 2018, 10:25:46 AM6/15/18
to AWX Project
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

Will Thames

unread,
Jul 16, 2018, 6:55:03 AM7/16/18
to AWX Project


On Friday, June 15, 2018 at 11:29:03 PM UTC+10, mamado...@gmail.com wrote:
Hello Sujith,

It's m

Le vendredi 15 juin 2018 10:52:04 UTC+2, Sujith A R a écrit :
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.
 
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)
Reply all
Reply to author
Forward
0 new messages