46db541181f2b863868479fd9b8f135750e5760f
[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 distribution
21   set_fact:
22     distro: "{{ ansible_distribution | lower }}{{ ansible_distribution_version | replace('.','') }}"
23
24 - name: Log distribution to console
25   debug:
26     msg: 'Set distribution to {{ distro }}'
27
28 - name: Fail if distribution is not valid for stack '{{ stack_type }}'
29   fail:
30     msg: "'{{ distro }}' is not a valid distribution for stack '{{ stack_type }}'"
31   when: distro not in distros
32
33 - name: Set provisioner type
34   set_fact:
35     provisioner_type: "{{ details.type is defined | ternary('bifrost', 'heat') }}"
36
37 - name: Log provisioner type to console
38   debug:
39     msg: 'Set provisioner type to {{ provisioner_type }}'
40
41 - name: Fail if the selected provisioner is not valid for stack '{{ stack_type }}'
42   fail:
43     msg: "'{{ provisioner_type }}' is not a valid provisioner for stack '{{ stack_type }}'"
44   when: provisioner_type not in provisioners
45
46 - name: Set installer type
47   set_fact:
48     installer_type: 'kubespray'
49   when: deploy_scenario is search('k8-')
50
51 - name: Log installer type to console
52   debug:
53     msg: 'Set installer type to {{ installer_type }}'
54
55 - name: Fail if the selected installer is not valid for stack '{{ stack_type }}'
56   fail:
57     msg: "'{{ installer_type }}' is not a valid installer for stack '{{ stack_type }}'"
58   when: installer_type not in installers
59
60 - name: Log deploy scenario to console
61   debug:
62     msg: 'Set deploy scenario to {{ deploy_scenario }}'
63
64 - name: Fail if the deploy scenario is not valid for stack '{{ stack_type }}'
65   fail:
66     msg: "'{{ deploy_scenario }}' is not valid for stack '{{ stack_type }}'"
67   when: deploy_scenario not in scenarios
68
69 # NOTE (fdegir): as we determine things dynamically, we need to record variables in order
70 # for them to become available subsequent tasks, roles, playbooks
71 - name: Record deployment variables to deployment variables file
72   blockinfile:
73     path: "{{ deployment_vars_file }}"
74     state: present
75     create: true
76     block: |
77       distro: "{{ distro }}"
78       provisioner_type: "{{ provisioner_type }}"
79       installer_type: "{{ installer_type }}"
80     marker: "# {mark} ANSIBLE MANAGED BLOCK engine-kubernetes"
81
82 - name: Reload deployment variables
83   include_vars: "{{ deployment_vars_file }}"
84
85 # NOTE (fdegir): Prepare provisioner and installer
86 - name: Prepare provisioner and installer for {{ execution_mode }}
87   include_tasks: "configure-{{ execution_mode }}.yaml"
88
89 # vim: set ts=2 sw=2 expandtab: