tasks: python: Add support for python3 environments
The venv and the Ceph modules could be based on python3 (eg openSUSE Leap 15) so we must determine the correct paths during runtime. Change-Id: Ie64c0ad96c11bf5d6041b41f8d34b1c3d03e824e
This commit is contained in:
parent
9bf4a212ff
commit
478d0a1972
|
@ -13,20 +13,33 @@
|
|||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
- name: Find the venv's python version
|
||||
find:
|
||||
paths: "{{ openstack_service_venv_bin | dirname }}/lib/"
|
||||
patterns: "python*"
|
||||
file_type: directory
|
||||
recurse: no
|
||||
register: python_venv_details
|
||||
|
||||
- name: Set python venvs details
|
||||
set_fact:
|
||||
venv_python_lib_folder: "{{ python_venv_details.files[0].path }}"
|
||||
ceph_python_interp: "/usr/bin/{{ ((python_venv_details.files[0].path | basename)[:-2] == 'python3') | ternary('python3', 'python') }}"
|
||||
|
||||
- name: Register rados module path
|
||||
command: python -c 'import rados; print rados.__file__'
|
||||
command: "{{ ceph_python_interp }} -c 'import rados; print(rados.__file__)'"
|
||||
changed_when: false
|
||||
register: rados_module_path
|
||||
|
||||
- name: Register rbd module path
|
||||
command: python -c 'import rbd; print rbd.__file__'
|
||||
command: "{{ ceph_python_interp }} -c 'import rbd; print(rbd.__file__)'"
|
||||
changed_when: false
|
||||
register: rbd_module_path
|
||||
|
||||
- name: Link rados module into the venv
|
||||
file:
|
||||
src: "{{ rados_module_path.stdout }}"
|
||||
dest: "{{ openstack_service_venv_bin | dirname }}/lib/python2.7/site-packages/{{ rados_module_path.stdout | basename }}"
|
||||
dest: "{{ venv_python_lib_folder }}/site-packages/{{ rados_module_path.stdout | basename }}"
|
||||
state: link
|
||||
force: "yes"
|
||||
notify:
|
||||
|
@ -35,7 +48,7 @@
|
|||
- name: Link rbd module into the venv
|
||||
file:
|
||||
src: "{{ rbd_module_path.stdout }}"
|
||||
dest: "{{ openstack_service_venv_bin | dirname }}/lib/python2.7/site-packages/{{ rbd_module_path.stdout | basename }}"
|
||||
dest: "{{ venv_python_lib_folder }}/site-packages/{{ rbd_module_path.stdout | basename }}"
|
||||
state: link
|
||||
force: "yes"
|
||||
notify:
|
||||
|
|
Loading…
Reference in New Issue