Use union for list combinations to ensure uniqueness

Rather than adding two lists together then passing them through
the 'unique' filter to remove duplicates, we combine the two
actions by using the union filter.

Change-Id: I8b032f3b5d043e543c1d0fd0434d833385ceecc4
This commit is contained in:
Jesse Pretorius 2019-03-20 05:55:10 +00:00
parent b84199341f
commit eb167317c2
2 changed files with 3 additions and 3 deletions

View File

@ -20,7 +20,7 @@
- name: Install distro packages for venv build
package:
name: "{{ (venv_wheel_build_enable | bool) | ternary(venv_install_distro_package_list, (venv_build_base_distro_package_list + venv_build_distro_package_list + venv_install_distro_package_list) | unique) }}"
name: "{{ (venv_wheel_build_enable | bool) | ternary(venv_install_distro_package_list, (venv_build_base_distro_package_list | union(venv_build_distro_package_list) | union(venv_install_distro_package_list)) }}"
state: "{{ venv_distro_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}"
@ -109,7 +109,7 @@
- name: Install python packages into the venv
pip:
name: "{{ (venv_default_pip_packages + venv_pip_packages) | unique | sort }}"
name: "{{ (venv_default_pip_packages | union(venv_pip_packages)) | sort }}"
state: "{{ venv_pip_package_state }}"
virtualenv: "{{ venv_install_destination_path }}"
extra_args: >-

View File

@ -21,7 +21,7 @@
block:
- name: Install distro packages for wheel build
package:
name: "{{ (venv_build_base_distro_package_list + venv_build_distro_package_list) | unique }}"
name: "{{ venv_build_base_distro_package_list | union(venv_build_distro_package_list) }}"
state: "{{ venv_distro_package_state }}"
update_cache: "{{ (ansible_pkg_mgr in ['apt', 'zypper']) | ternary('yes', omit) }}"
cache_valid_time: "{{ (ansible_pkg_mgr == 'apt') | ternary(venv_distro_cache_valid_time, omit) }}"