From 522a78385a804c7ba02da0e0ebc31d9a82c8bc4d Mon Sep 17 00:00:00 2001 From: Michal Date: Tue, 27 Oct 2020 14:43:13 +0100 Subject: [PATCH] Allow bindep role to read from more then one bindep file Extend bindep role to be able to install packages from multiple paths at once. This behavior is fully compatible with current implementation, however it allows to pass number of bindep file paths. Change-Id: I70d42f25837ff282aad534f9ead965d12858ac9b --- roles/bindep/README.rst | 2 +- roles/bindep/tasks/main.yaml | 9 ++++++--- roles/bindep/tasks/packages.yaml | 6 +++++- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/roles/bindep/README.rst b/roles/bindep/README.rst index 5f28344a5..1acd71341 100644 --- a/roles/bindep/README.rst +++ b/roles/bindep/README.rst @@ -19,7 +19,7 @@ then install the missing packages. .. zuul:rolevar:: bindep_file - Path to a specific bindep file to read from. + Path or list of paths to a specific bindep file(s) to read from. .. zuul:rolevar:: bindep_command diff --git a/roles/bindep/tasks/main.yaml b/roles/bindep/tasks/main.yaml index da87414e8..b4d1472fa 100644 --- a/roles/bindep/tasks/main.yaml +++ b/roles/bindep/tasks/main.yaml @@ -10,10 +10,13 @@ - bindep_file is defined - bindep_command is not defined -- name: Define bindep_run fact +- name: Convert bindep_file to list set_fact: - bindep_run: "{{ bindep_command }} -b -f {{ bindep_file }} {{ bindep_profile }}" - when: bindep_file is defined + bindep_file: "{{ [bindep_file] }}" + when: bindep_file is defined and bindep_file is string - include_tasks: packages.yaml + loop: "{{ bindep_file }}" + loop_control: + loop_var: zj_bindep_file when: bindep_file is defined diff --git a/roles/bindep/tasks/packages.yaml b/roles/bindep/tasks/packages.yaml index 73fd80d9a..2baba396f 100644 --- a/roles/bindep/tasks/packages.yaml +++ b/roles/bindep/tasks/packages.yaml @@ -1,3 +1,7 @@ +- name: Define bindep_run fact + set_fact: + bindep_run: "{{ bindep_command }} -b -f {{ zj_bindep_file }} {{ bindep_profile }}" + - name: Get list of packages to install from bindep command: "{{ bindep_run }}" register: bindep_output @@ -21,5 +25,5 @@ - name: Fail if we cannot install all packages fail: - msg: "bindep failed to install from {{ bindep_file }} - {{ bindep_final_check.stdout }}" + msg: "bindep failed to install from {{ zj_bindep_file }} - {{ bindep_final_check.stdout }}" when: bindep_final_check is failed