diff --git a/defaults/main.yml b/defaults/main.yml index 167a1f3..334c118 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -26,6 +26,9 @@ repo_build_pool_dir: "/var/www/repo/pools" repo_build_release_tag: "untagged" +# Toggle whether venvs should be built selectively or not +repo_build_venv_selective: yes + # Optionally set this to change the default index from pypi to an alternative #repo_build_pip_default_index: "https://pypi.python.org/simple" diff --git a/releasenotes/notes/selective-venv-build-dd9f0e40cd1cc076.yaml b/releasenotes/notes/selective-venv-build-dd9f0e40cd1cc076.yaml new file mode 100644 index 0000000..801a133 --- /dev/null +++ b/releasenotes/notes/selective-venv-build-dd9f0e40cd1cc076.yaml @@ -0,0 +1,8 @@ +--- +features: + - The repo build process now selectively builds venvs based on + whether each OpenStack service group has any hosts in it. If + there are no hosts in the group, the venv will not be built. + This behaviour can be optionally changed to force all venvs + to be built by setting ``repo_build_venv_selective`` to + ``yes``. diff --git a/templates/op-venv-script.sh.j2 b/templates/op-venv-script.sh.j2 index 8aedc6e..952507c 100644 --- a/templates/op-venv-script.sh.j2 +++ b/templates/op-venv-script.sh.j2 @@ -47,7 +47,8 @@ function venv_create { # purposes the group data will be rendered as a comment. {% set os_group = {} %} {% for key, value in local_packages.results.0.item.role_packages.items() %} -{% if "os_" in key %} +{% set _host_group = key | replace('os_', '') + '_all' %} +{% if ("os_" in key) and (not repo_build_venv_selective | bool) or ((groups[_host_group] is defined) and (groups[_host_group] | length > 0)) %} # venv to build {{ key }} # * packages within the {{ key }} venv: {{ value }} {% set _ = os_group.update({key: value}) %} diff --git a/tests/inventory b/tests/inventory index 337d7b0..7191987 100644 --- a/tests/inventory +++ b/tests/inventory @@ -7,3 +7,7 @@ container1 [all_containers:children] repo_all + +# This is here to validate the venv build inclusion +[keystone_all] +container1 diff --git a/tests/test-repo-build.yml b/tests/test-repo-build.yml index 7d33903..2507e5c 100644 --- a/tests/test-repo-build.yml +++ b/tests/test-repo-build.yml @@ -39,5 +39,15 @@ roles: - "repo_server" - "{{ rolename | basename }}" + post_tasks: + - name: List the files in the venv folder + command: ls -1 /var/www/repo/venvs/{{ repo_build_release_tag }}/{{ ansible_distribution | lower }}/ + register: venv_folder_content + - name: Ensure that the keystone venv is present + assert: + that: "'keystone-{{ repo_build_release_tag }}.tgz' in venv_folder_content.stdout" + - name: Ensure that the nova venv is NOT present + assert: + that: "'nova-{{ repo_build_release_tag }}.tgz' not in venv_folder_content.stdout" vars_files: - test-vars.yml diff --git a/tests/test-vars.yml b/tests/test-vars.yml index 343e784..94d1ce7 100644 --- a/tests/test-vars.yml +++ b/tests/test-vars.yml @@ -14,6 +14,7 @@ # limitations under the License. openstack_release: testing +repo_build_release_tag: "{{ openstack_release }}" galera_client_drop_config_file: false local_packages: results: