diff --git a/playbooks/roles/bifrost-create-dib-image/defaults/main.yml b/playbooks/roles/bifrost-create-dib-image/defaults/main.yml index 514fc4067..7f0eda68c 100644 --- a/playbooks/roles/bifrost-create-dib-image/defaults/main.yml +++ b/playbooks/roles/bifrost-create-dib-image/defaults/main.yml @@ -16,3 +16,9 @@ dib_notmpfs: false dib_offline: false dib_skipbase: false dib_packages: "" +# Settings related to installing bifrost in a virtual environment +enable_venv: false +bifrost_venv_dir: "{{ lookup('env', 'VENV') | default('/opt/stack/bifrost') }}" +bifrost_venv_env: + VIRTUAL_ENV: "{{ bifrost_venv_dir }}" + PATH: "{{ bifrost_venv_dir }}/bin:{{ ansible_env.PATH }}" # include regular path via lookup env diff --git a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml index 699701592..07b9aaac9 100644 --- a/playbooks/roles/bifrost-create-dib-image/tasks/main.yml +++ b/playbooks/roles/bifrost-create-dib-image/tasks/main.yml @@ -120,11 +120,11 @@ dib_arglist: "{{dib_trace_arg|default('')}} {{dib_uncompressed_arg|default('')}} {{dib_clearenv_arg|default('')}} {{dib_notmpfs_arg|default('')}} {{dib_offline_arg|default('')}} {{dib_skipbase_arg|default('')}} {{dib_arch_arg|default('')}} {{dib_imagename_arg|default('')}} {{dib_imagetype_arg|default('')}} {{dib_imagesize_arg|default('')}} {{dib_imagecache_arg|default('')}} {{dib_maxresize_arg|default('')}} {{dib_mintmpfs_arg|default('')}} {{dib_mkfsopts_arg|default('')}} {{dib_qemuopts_arg|default('')}} {{dib_rootlabel_arg|default('')}} {{dib_rdelement_arg|default('')}} {{dib_installtype_arg|default('')}} {{dib_packages_arg|default('')}} {{dib_os_element}} {{dib_elements|default('')}}" - name: "Initiate image build" command: disk-image-create {{dib_arglist}} - environment: "{{ dib_env_vars_final }}" + environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else '{}') }}" when: build_ramdisk | bool == false and test_image_present.stat.exists == false and test_image_dib_present.stat.exists == false and test_image_initramfs_present.stat.exists == false - name: "Initiate ramdisk build" command: ramdisk-image-create {{dib_arglist}} - environment: "{{ dib_env_vars_final }}" + environment: "{{ dib_env_vars_final | combine(bifrost_venv_env if enable_venv|bool else '{}') }}" when: build_ramdisk | bool == true and test_image_present.stat.exists == false and test_image_dib_present.stat.exists == false and test_image_initramfs_present.stat.exists == false - name: "Update permission of generated image" file: diff --git a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml index e76fb64fb..cb6cf8c3d 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/defaults/main.yml @@ -32,3 +32,9 @@ test_vm_emulator: "/usr/bin/qemu-system-x86_64" test_vm_machine: "pc-1.0" # NOTE(pas-ha) not really tested with non-local qemu connections test_vm_libvirt_uri: "{{ lookup('env', 'LIBVIRT_CONNECT_URI') | default('qemu:///system', true) }}" +# Settings related to installing bifrost in a virtual environment +enable_venv: false +bifrost_venv_dir: "{{ lookup('env', 'VENV') | default('/opt/stack/bifrost') }}" +bifrost_venv_env: + VIRTUAL_ENV: "{{ bifrost_venv_dir }}" + PATH: "{{ bifrost_venv_dir }}/bin:{{ ansible_env.PATH }}" # include regular path via lookup env diff --git a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml index e945d9479..37be5089a 100644 --- a/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml +++ b/playbooks/roles/bifrost-create-vm-nodes/tasks/create_vm.yml @@ -98,10 +98,12 @@ - name: get list of nodes from virtualbmc command: vbmc list register: vbmc_list + environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" # NOTE(NobodyCam): Space at the end of the find clause is required for proper matching. - name: delete vm from virtualbmc if it is there command: vbmc delete {{ vm_name }} + environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" when: vbmc_list.stdout.find("{{ vm_name }} ") != -1 - set_fact: @@ -109,9 +111,11 @@ - name: plug vm into vbmc command: vbmc add {{ vm_name }} --libvirt-uri {{ test_vm_libvirt_uri }} --port {{ virtual_ipmi_port }} + environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" - name: start virtualbmc command: vbmc start {{ vm_name }} + environment: "{{ bifrost_venv_env if enable_venv else '{}' }}" - name: get XML of the vm virt: