You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The current solution compares the package names in the venv to the base image only resulting in the derived image losing the version specified in the venv.
The assumption is that most packages with specific versions required are packages in addition to what's installed by the base Ansible requirements in support of other modules, roles, and collections.
Gather pip freeze from the base image and each venv
Split the output on == in each line and build a new dictionary
Loop over venv keys (package name)
If venv package name is not in base package keys() add to new var (packages_to_install)
Essentially, perform the comparison at a name level, but install a specific version if the package doesn't exist in the base already.
Sample Solution Code
- name: VENV PACKAGES AND VERSIONS SPLITansible.builtin.set_fact:
venv_package_details: "{{ venv_package_details | default({}) | combine({item.split('==')[0]: item.split('==')[1]}) }}"loop: "{{ venv_packages }}"
- name: BASE PACKAGES AND VERSIONS SPLITansible.builtin.set_fact:
base_package_details: "{{ base_package_details | default({}) | combine({item.split('==')[0]: item.split('==')[1]}) }}"loop: "{{ base_packages }}"
- name: CREATE NEW WITH VERSIONansible.builtin.set_fact:
packages_to_install: "{{ packages_to_install | default([]) + [item.key + '==' + item.value] }}"loop: "{{ venv_package_details | dict2items }}"when:
- item.key not in base_package_details.keys()
- not item.key is search('ansible')
...working on integrating similar code into the existing role and PR...
The text was updated successfully, but these errors were encountered:
The current solution compares the package names in the
venv
to the base image only resulting in the derived image losing the version specified in thevenv
.The assumption is that most packages with specific versions required are packages in addition to what's installed by the base Ansible requirements in support of other modules, roles, and collections.
pip freeze
from the base image and each venv==
in each line and build a new dictionarypackages_to_install
)Essentially, perform the comparison at a name level, but install a specific version if the package doesn't exist in the base already.
Sample Solution Code
...working on integrating similar code into the existing role and PR...
The text was updated successfully, but these errors were encountered: