Introduce stack setup script
[infra/stack/kubernetes.git] / playbooks / roles / bootstrap-swconfig / tasks / main.yaml
1 ---
2 # ============LICENSE_START=======================================================
3 #  Copyright (C) 2019 The Nordix Foundation. All rights reserved.
4 # ================================================================================
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at
8 #
9 #      http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16 #
17 # SPDX-License-Identifier: Apache-2.0
18 # ============LICENSE_END=========================================================
19
20 - name: Set deploy scenario
21   set_fact:
22     deploy_scenario: "{{ lookup('env', 'DEPLOY_SCENARIO') | default('k8-multus-plugins', true) }}"
23
24 - name: Log deploy scenario to console
25   debug:
26     msg: 'Set deploy scenario to {{ deploy_scenario }}'
27
28 - name: Fail if the deploy scenario is not valid for stack '{{ stack_type }}'
29   fail:
30     msg: "'{{ deploy_scenario }}' is not valid for stack '{{ stack_type }}'"
31   when: deploy_scenario not in scenarios
32
33 - name: Log distribution to console
34   debug:
35     msg: 'Set distribution to {{ distro }}'
36
37 - name: Fail if distribution is not valid for stack '{{ stack_type }}'
38   fail:
39     msg: "'{{ distro }}' is not a valid distribution for stack '{{ stack_type }}'"
40   when: distro not in distros
41
42 - name: Set provisioner type
43   set_fact:
44     provisioner_type: "{{ details.type is defined | ternary('bifrost', 'heat') }}"
45
46 - name: Log provisioner type to console
47   debug:
48     msg: 'Set provisioner type to {{ provisioner_type }}'
49
50 - name: Fail if the selected provisioner is not valid for stack '{{ stack_type }}'
51   fail:
52     msg: "'{{ provisioner_type }}' is not a valid provisioner for stack '{{ stack_type }}'"
53   when: provisioner_type not in provisioners
54
55 - name: Set installer type
56   set_fact:
57     installer_type: 'kubespray'
58   when: deploy_scenario is search('k8-')
59
60 - name: Log installer type to console
61   debug:
62     msg: 'Set installer type to {{ installer_type }}'
63
64 - name: Fail if the selected installer is not valid for stack '{{ stack_type }}'
65   fail:
66     msg: "'{{ installer_type }}' is not a valid installer for stack '{{ stack_type }}'"
67   when: installer_type not in installers
68
69
70 # NOTE (fdegir): as we determine things dynamically, we need to record variables in order
71 # for them to become available subsequent tasks, roles, playbooks
72 - name: Record deployment variables to deployment variables file
73   blockinfile:
74     path: "{{ deployment_vars_file }}"
75     state: present
76     create: true
77     block: |
78       deploy_scenario: "{{ deploy_scenario }}"
79       provisioner_type: "{{ provisioner_type }}"
80       installer_type: "{{ installer_type }}"
81     marker: "# {mark} ANSIBLE MANAGED BLOCK engine-kubernetes"
82
83 - name: Reload deployment variables
84   include_vars: "{{ deployment_vars_file }}"
85
86 # NOTE (fdegir): Prepare provisioner and installer
87 - name: Prepare provisioner and installer for {{ execution_mode }}
88   include_tasks: "configure-{{ execution_mode }}.yaml"
89
90 # vim: set ts=2 sw=2 expandtab: