X-Git-Url: https://gerrit.nordix.org/gitweb?p=infra%2Fstack%2Fkubernetes.git;a=blobdiff_plain;f=playbooks%2Froles%2Fbootstrap-swconfig%2Ftasks%2Fmain.yaml;fp=playbooks%2Froles%2Fbootstrap-swconfig%2Ftasks%2Fmain.yaml;h=46db541181f2b863868479fd9b8f135750e5760f;hp=0000000000000000000000000000000000000000;hb=20d34e772e021fabdee0aa9b50e9804a80d5108a;hpb=0ee637017774692ae73514e146f25c8973c3bffe diff --git a/playbooks/roles/bootstrap-swconfig/tasks/main.yaml b/playbooks/roles/bootstrap-swconfig/tasks/main.yaml new file mode 100644 index 0000000..46db541 --- /dev/null +++ b/playbooks/roles/bootstrap-swconfig/tasks/main.yaml @@ -0,0 +1,89 @@ +--- +# ============LICENSE_START======================================================= +# Copyright (C) 2019 The Nordix Foundation. All rights reserved. +# ================================================================================ +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# +# SPDX-License-Identifier: Apache-2.0 +# ============LICENSE_END========================================================= + +- name: Set distribution + set_fact: + distro: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.','') }}" + +- name: Log distribution to console + debug: + msg: 'Set distribution to {{ distro }}' + +- name: Fail if distribution is not valid for stack '{{ stack_type }}' + fail: + msg: "'{{ distro }}' is not a valid distribution for stack '{{ stack_type }}'" + when: distro not in distros + +- name: Set provisioner type + set_fact: + provisioner_type: "{{ details.type is defined | ternary('bifrost', 'heat') }}" + +- name: Log provisioner type to console + debug: + msg: 'Set provisioner type to {{ provisioner_type }}' + +- name: Fail if the selected provisioner is not valid for stack '{{ stack_type }}' + fail: + msg: "'{{ provisioner_type }}' is not a valid provisioner for stack '{{ stack_type }}'" + when: provisioner_type not in provisioners + +- name: Set installer type + set_fact: + installer_type: 'kubespray' + when: deploy_scenario is search('k8-') + +- name: Log installer type to console + debug: + msg: 'Set installer type to {{ installer_type }}' + +- name: Fail if the selected installer is not valid for stack '{{ stack_type }}' + fail: + msg: "'{{ installer_type }}' is not a valid installer for stack '{{ stack_type }}'" + when: installer_type not in installers + +- name: Log deploy scenario to console + debug: + msg: 'Set deploy scenario to {{ deploy_scenario }}' + +- name: Fail if the deploy scenario is not valid for stack '{{ stack_type }}' + fail: + msg: "'{{ deploy_scenario }}' is not valid for stack '{{ stack_type }}'" + when: deploy_scenario not in scenarios + +# NOTE (fdegir): as we determine things dynamically, we need to record variables in order +# for them to become available subsequent tasks, roles, playbooks +- name: Record deployment variables to deployment variables file + blockinfile: + path: "{{ deployment_vars_file }}" + state: present + create: true + block: | + distro: "{{ distro }}" + provisioner_type: "{{ provisioner_type }}" + installer_type: "{{ installer_type }}" + marker: "# {mark} ANSIBLE MANAGED BLOCK engine-kubernetes" + +- name: Reload deployment variables + include_vars: "{{ deployment_vars_file }}" + +# NOTE (fdegir): Prepare provisioner and installer +- name: Prepare provisioner and installer for {{ execution_mode }} + include_tasks: "configure-{{ execution_mode }}.yaml" + +# vim: set ts=2 sw=2 expandtab: