create virtualenv with pip modle and centos scl (rh-python36)

287 views
Skip to first unread message

Peter Hudec

unread,
Mar 21, 2019, 4:40:15 PM3/21/19
to ansible...@googlegroups.com
Hi all,

I’m trying to solve following problem.

I need to create virtualenv for python using centos scl rh-python36

Manual way is easy, there are several way how to do that

/opt/rh/rh-python36/root/bin/python -m venv env
. ./env/bin/activate
pip install -U pip setuptools
pip install -t requirements.txt

But but with ansible I’m a little bit lost.

- name: create virtualenv
pip:
virtualenv: "{{ haproxy_tools_remote_dir }}/{{ haproxy_tools_version }}/env"
virtualenv_python: "/opt/rh/{{ haproxy_tools_scl_python }}/root/bin/python"
requirements: "{{ haproxy_tools_remote_dir }}/{{ haproxy_tools_version }}/requirements.txt"
tags:
- debug

The output is
fatal: [lb01.test.host.sk]: FAILED! => {"changed": false, "msg": "No setuptools found in remote host, please install it first.”}

Any idea, please ?

regards
Peter

Matt Martz

unread,
Mar 21, 2019, 4:51:21 PM3/21/19
to ansible...@googlegroups.com
I believe the problem is that the system python at /usr/bin/python doesn't have python-setuptools installed

You would need to either install python-setuptools via yum, or set `ansible_python_interpreter` to `/opt/rh/rh-python36/root/bin/python` so that ansible is using that SCL python also.

By default ansible will use /usr/bin/python on the remote, and use that to configure the virtualenv, but configure the virtualenv to use the SCL python.  So basically ansible is using 1 python to run another.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-proje...@googlegroups.com.
To post to this group, send email to ansible...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/E255A9C5-493C-4EC1-8C79-71E55F69404F%40home.hudecof.net.
For more options, visit https://groups.google.com/d/optout.


--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages