diff options
Diffstat (limited to 'xci/playbooks/get-opnfv-scenario-requirements.yml')
-rw-r--r-- | xci/playbooks/get-opnfv-scenario-requirements.yml | 165 |
1 files changed, 82 insertions, 83 deletions
diff --git a/xci/playbooks/get-opnfv-scenario-requirements.yml b/xci/playbooks/get-opnfv-scenario-requirements.yml index 7eaa43de..a9165709 100644 --- a/xci/playbooks/get-opnfv-scenario-requirements.yml +++ b/xci/playbooks/get-opnfv-scenario-requirements.yml @@ -31,15 +31,88 @@ loop_control: label: "{{ item[0].scenario }}" - - name: Create scenario directories - file: - path: "{{ role_path_default }}/{{ item.scenario }}" - state: directory + - 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: Collect list of known scenarions + set_fact: + known_scenarios: > + {%- set scenario_names = [] -%} + {%- for x in scenarios -%} + {%- set _ = scenario_names.append(x.scenario) -%} + {%- endfor -%} + {{- scenario_names -}} with_items: "{{ scenarios }}" loop_control: label: "{{ item.scenario }}" - - name: Clone git repos (with git) + - name: Fail if 'DEPLOY_SCENARIO' is not defined + fail: + msg: "DEPLOY_SCENARIO env variable is not defined so no scenario can be deployed" + when: deploy_scenario is not defined + + - name: Ensure {{ deploy_scenario }} is a known XCI scenario + fail: + msg: "{{ deploy_scenario }} does not exist" + when: deploy_scenario not in known_scenarios + + - name: Collect scenario information + set_fact: + xci_scenario: > + {%- set xci_scenario = {} -%} + {%- for x in scenarios if x.scenario == deploy_scenario -%} + {%- for z in x.installers if z.installer == installer_type -%} + {%- set _ = xci_scenario.update({'flavors': z.flavors}) -%} + {%- set _ = xci_scenario.update({'distros': z.distros}) -%} + {%- endfor -%} + {%- set _ = xci_scenario.update({'role': x.role | basename}) -%} + {%- endfor -%} + {{ xci_scenario }} + + - name: Ensure local facts directory exists + file: + path: "/etc/ansible/facts.d" + state: directory + become: true + + - name: Record scenario information + ini_file: + create: yes + section: scenarios + state: present + option: role + value: "{{ xci_scenario.role | basename }}" + path: "/etc/ansible/facts.d/xci.fact" + become: true + + - name: Fail if {{ deploy_scenario }} is not supported + fail: + msg: + - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + - ERROR! The {{ deploy_scenario }} scenario can't be deployed. This is because + - the {{ installer_type }} XCI installer or the {{ xci_flavor }} flavor or the {{ xci_distro }} + - distribution is not supported by this scenario. It may also be possible that + - this scenario doesn't exist at all or it's not listed in {{ scenario_file }}. + - '' + - This is a great chance for you to contribute to XCI ;-) + - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + - '' + when: + (xci_scenario['flavors'] is defined and xci_flavor not in xci_scenario['flavors']) or + (xci_scenario['distros'] is defined and xci_distro not in xci_scenario['distros']) + + - name: Clone git repos git: repo: "{{ item.src }}" dest: "{{ scenario_path_default }}/{{ item.scenario | default(item.src | basename) }}" @@ -47,8 +120,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,91 +128,19 @@ loop_control: label: "{{ item.scenario }}" - - name: Check that scenarios exist - stat: - path: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}" - register: scenarios_list_exists - 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.scenario }}" - when: item.stat.exists - with_items: "{{ scenarios_list_exists.results }}" - loop_control: - label: "{{ item.item.scenario }}" - - - name: Synchronize local changes to scenarios' master branch + - name: Plug in the scenario Ansible roles to XCI synchronize: - src: "{{ XCI_PATH }}/{{ item.item.role }}/" - dest: "{{ role_path_default }}/{{ item.item.scenario }}" - 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.scenario }}" - 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 }}" + src: "{{ scenario_path_default }}/{{ item.scenario }}/{{ item.role }}/" + dest: "{{ role_path_default }}/{{ item.role | basename }}" with_items: "{{ scenarios }}" loop_control: label: "{{ item.scenario }}" - when: DEPLOY_SCENARIO | lower == item.scenario - - - name: Determine if the selected {{ DEPLOY_SCENARIO }} scenario can be deployed - block: - - set_fact: - deploy_scenario_installer: "{{ item }}" - with_items: "{{ deploy_scenario.installers }}" - loop_control: - label: "{{ item.installer }}" - when: item.installer == XCI_INSTALLER - - set_fact: - deploy_scenario_flavor: "{{ (XCI_FLAVOR in deploy_scenario_installer.flavors) | bool }}" - when: - - deploy_scenario_installer - - set_fact: - deploy_scenario_distro: "{{ (XCI_DISTRO in deploy_scenario_installer.distros) | bool }}" - when: - - deploy_scenario_installer - - deploy_scenario_flavor - when: deploy_scenario is defined - - - name: Fail if {{ DEPLOY_SCENARIO }} is not supported - fail: - msg: - - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - ERROR! The {{ DEPLOY_SCENARIO }} scenario can't be deployed. This is because - - the {{ XCI_INSTALLER }} XCI installer or the {{ XCI_FLAVOR }} flavor or the {{ XCI_DISTRO }} - - distribution is not supported by this scenario. It may also be possible that - - this scenario doesn't exist at all or it's not listed in {{ scenario_file }}. - - '' - - This is a great chance for you to contribute to XCI ;-) - - ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ - - '' - when: - - deploy_scenario is not defined or not deploy_scenario_distro vars: ansible_python_interpreter: "/usr/bin/python" scenarios: "{{ lookup('file', scenario_file) | from_yaml }}" scenario_file: '../opnfv-scenario-requirements.yml' - scenario_path_default: "{{ XCI_SCENARIOS_CACHE }}" + scenario_path_default: "{{ xci_scenarios_cache }}" role_path_default: "{{ playbook_dir }}/roles" git_clone_retries: 2 git_clone_retry_delay: 5 |