From 478d0a197223045352359876b0be9451fd2acb29 Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 8 Nov 2018 13:07:05 +0000 Subject: [PATCH] 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 --- tasks/ceph_install_python_libs.yml | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/tasks/ceph_install_python_libs.yml b/tasks/ceph_install_python_libs.yml index 3859c96..5c812e7 100644 --- a/tasks/ceph_install_python_libs.yml +++ b/tasks/ceph_install_python_libs.yml @@ -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: