Right now we're looping in the wrong place: instead of
unconditionally adding to the flattened list of pip packages and
then calling pip multiple times with that same list, we should
conditionally add items to the flattened list and then call pip
a single time with the result.
Signed-off-by: Andrea Bolognani <abologna(a)redhat.com>
---
guests/playbooks/update/tasks/packages.yml | 16 +++++++++-------
1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/guests/playbooks/update/tasks/packages.yml
b/guests/playbooks/update/tasks/packages.yml
index 116c46d..fc8a3d1 100644
--- a/guests/playbooks/update/tasks/packages.yml
+++ b/guests/playbooks/update/tasks/packages.yml
@@ -121,6 +121,15 @@
when:
- pip_mappings[item]["default"] is defined
+- name: '{{ project }}: Remove unwanted pip mappings'
+ set_fact:
+ pip_resolved: '{{ pip_resolved|combine({ item: None }) }}'
+ with_items:
+ '{{ packages }}'
+ when:
+ - resolved[item] is defined
+ - resolved[item] != None
+
- set_fact:
pip_flattened: []
@@ -138,10 +147,3 @@
name: '{{ pip_flattened|sort }}'
executable: pip3
state: '{{ state }}'
- with_items:
- '{{ packages }}'
- when:
- - resolved[item] is defined
- - resolved[item] == None
- - pip_resolved[item] is defined
- - pip_resolved[item] != None
--
2.24.1