From c10fb5f0aceee722f34f5963c4bdbea3e32a7a7f Mon Sep 17 00:00:00 2001 From: Markos Chandras Date: Thu, 26 Apr 2018 09:38:54 +0100 Subject: xci: playbooks: Simplify scenario overrides mechanism Now that releng-xci does not have any internal scenarios anymore, we can simplify the way we plug scenarios to XCI. We keep cloning scenarios in the cache directory but we also allow users to pass a special 'xci_scenarios_overrides' variable similar to the 'opnfv_scenario_requirements.yml' file to allow them to override specific keys of the dictionaries. This can be used by Jenkins to test incoming changes by altering the defaults values. For example, when we want to test a Gerrit change we can create a file called foobar.yml with the following contents xci_scenarios_overrides: - scenario: os-odl-sfc version: 9fa5400012e02408b416eb7bd26307e7d179abce refspec: refs/changes/79/55879/7 and load it using XCI_ANSIBLE_PARAMS="-e @foobar.yml" This will make XCI checkout the refspec that we want instead of the default version. Change-Id: Ida49910b4c79b843582ddd70c00063fe9bc90dd4 Signed-off-by: Markos Chandras --- xci/playbooks/get-opnfv-scenario-requirements.yml | 66 ++++++----------------- 1 file changed, 16 insertions(+), 50 deletions(-) diff --git a/xci/playbooks/get-opnfv-scenario-requirements.yml b/xci/playbooks/get-opnfv-scenario-requirements.yml index af97ceb2..c05d06c0 100644 --- a/xci/playbooks/get-opnfv-scenario-requirements.yml +++ b/xci/playbooks/get-opnfv-scenario-requirements.yml @@ -31,15 +31,21 @@ loop_control: label: "{{ item[0].scenario }}" - - name: Create scenario directories - file: - path: "{{ role_path_default }}/{{ item.scenario }}" - state: directory - with_items: "{{ scenarios }}" + - name: Update scenarios with local overrides + set_fact: + scenarios: > + {%- for z in xci_scenarios_overrides -%} + {%- for x in scenarios if x.scenario == z.scenario -%} + {%- set _ = x.update(z) -%} + {%- endfor -%} + {%- endfor -%} + {{- scenarios -}} + with_items: "{{ xci_scenarios_overrides }}" loop_control: label: "{{ item.scenario }}" + when: xci_scenarios_overrides is defined - - name: Clone git repos (with git) + - name: Clone git repos git: repo: "{{ item.src }}" dest: "{{ scenario_path_default }}/{{ item.scenario | default(item.src | basename) }}" @@ -47,8 +53,6 @@ refspec: "{{ item.refspec | default(omit) }}" update: true force: true - when: - - item.scm == "git" or item.scm is undefined with_items: "{{ scenarios }}" register: git_clone until: git_clone | success @@ -57,52 +61,14 @@ loop_control: label: "{{ item.scenario }}" - - name: Check that scenarios exist - stat: - path: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}" - register: scenarios_list_exists + - name: Plug in the scenario Ansible roles to XCI + synchronize: + src: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}/" + dest: "{{ role_path_default }}/{{ item.role | basename }}" with_items: "{{ scenarios }}" loop_control: label: "{{ item.scenario }}" - - name: Plug in the scenario to XCI - synchronize: - src: "{{ scenario_path_default }}/{{ item.item.scenario }}/{{ item.item.role }}/" - dest: "{{ role_path_default }}/{{ item.item.role | basename }}" - when: item.stat.exists - with_items: "{{ scenarios_list_exists.results }}" - loop_control: - label: "{{ item.item.scenario }}" - - - name: Synchronize local changes to scenarios' master branch - synchronize: - src: "{{ xci_path }}/xci/scenarios/{{ item.item.scenario }}/{{ item.item.role | replace('xci/scenarios/' ~ item.item.scenario ~ '/', '') }}/" - dest: "{{ role_path_default }}/{{ item.item.role | basename }}" - archive: no - times: no - recursive: yes - checksum: yes - owner: yes - group: yes - perms: yes - links: yes - failed_when: false - when: - - item.stat.exists - - item.item.version == 'master' - with_items: "{{ scenarios_list_exists.results }}" - loop_control: - label: "{{ item.item.scenario }}" - - - name: Plug in the scenario to XCI (fallback) - synchronize: - src: "{{ xci_path }}/{{ item.item.role }}/" - dest: "{{ role_path_default }}/{{ item.item.role | basename }}" - when: not item.stat.exists - with_items: "{{ scenarios_list_exists.results }}" - loop_control: - label: "{{ item.item.scenario }}" - - name: Gather information about the selected {{ deploy_scenario }} scenario set_fact: deploy_scenario: "{{ item }}" -- cgit 1.2.3-korg