blob: d57dfa505bef42ba0a8c0c5e4f0958e4040461ad [file] [log] [blame]
Fatih Degirmenciccc68892019-02-27 09:16:45 +00001---
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: Remove existing files and directories
21 file:
22 path: "{{ engine_cache }}/repos/kubespray"
23 state: absent
24
25- name: Clone kubespray repository and checkout '{{ kubespray_version }}'
26 git:
27 repo: "{{ kubespray_git_url }}"
28 dest: "{{ engine_cache }}/repos/kubespray"
29 version: "{{ kubespray_version }}"
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000030 force: true
Wenqing Gufa739512019-08-21 09:29:23 +000031 environment: "{{ idf.proxy_settings | default({}) }}"
Fatih Degirmenciccc68892019-02-27 09:16:45 +000032
33# TODO: some stuff below could and perhaps should be pushed into the scenario
34# it is put here to make basic installation work without complexities
35- name: Put initial structure in place
36 synchronize:
37 src: "{{ engine_cache }}/repos/kubespray/inventory/sample/"
38 dest: "{{ engine_cache }}/repos/kubespray/inventory/engine"
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000039 recursive: true
40 delete: true
Fatih Degirmenciccc68892019-02-27 09:16:45 +000041
Fatih Degirmenci3646fcd2019-06-12 16:21:11 +020042# place generated kubespray inventory to kubespray/inventory/engine
43- name: Place inventory
44 copy:
Fatih Degirmenci71e0ebc2020-01-09 07:26:08 +000045 src: "{{ inventory_path }}/inventory.ini"
Fatih Degirmenci3646fcd2019-06-12 16:21:11 +020046 dest: "{{ engine_cache }}/repos/kubespray/inventory/engine/inventory.ini"
47 mode: 0644
48
Wenqing Gufa739512019-08-21 09:29:23 +000049# update proxy if settings are provided
50- name: Update proxy settings in all.yml
51 lineinfile:
52 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/all/all.yml"
53 regexp: "^[#\\s]*{{ item.name }}"
54 line: "{{ item.name }}: {{ item.value }}"
55 with_items:
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000056 - {name: 'http_proxy', value: '{{ idf.proxy_settings.http_proxy }}'}
57 - {name: 'https_proxy', value: '{{ idf.proxy_settings.https_proxy }}'}
58 - {name: 'no_proxy', value: '{{ idf.proxy_settings.no_proxy }}'}
Wenqing Gufa739512019-08-21 09:29:23 +000059 when:
60 idf.proxy_settings is defined
61
Wenqing Gu3d802212019-04-18 08:28:24 +020062# update ControlPersist to 60m to inline with max time
63- name: Update ControlPersist in ansible config
64 lineinfile:
65 path: "{{ engine_cache }}/repos/kubespray/ansible.cfg"
66 regexp: "^ssh_args.*"
67 line: "ssh_args = -o ControlMaster=auto -o ControlPersist=60m -o ConnectionAttempts=100 -o UserKnownHostsFile=/dev/null"
68
Fatih Degirmenci51a4f882019-03-19 17:35:15 +000069# enable helm for all the scenarios using kubespray
70- name: Enable helm
71 lineinfile:
72 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
73 regexp: "^helm_enabled:.*"
74 line: "helm_enabled: true"
75
Sriram Yagnaraman82bd8722019-11-21 16:08:48 +010076# enable metrics server for all the scenarios using kubespray
77- name: Enable metrics server
78 lineinfile:
79 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
80 regexp: "^metrics_server_enabled:.*"
81 line: "metrics_server_enabled: true"
82
83# enable metrics server metric resolution
84- name: Enable metrics server resolution
85 lineinfile:
86 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
87 regexp: "^#metrics_server_metric_resolution:.*"
88 line: "metrics_server_metric_resolution: 60s"
89
90# enable metrics server metric resolution
91- name: Enable metrics_server_kubelet_preferred_address_types
92 lineinfile:
93 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
94 regexp: "^#metrics_server_kubelet_preferred_address_types:.*"
95 line: "metrics_server_kubelet_preferred_address_types: 'InternalIP'"
96
Ignacio Pascual1f4a35e2020-02-13 13:56:48 +010097# disable kubernetes dashboard installation. It does not work with versions >=v1.16.0
98# https://github.com/kubernetes-sigs/kubespray/issues/5347
99- name: Disable kubernetes dashboard installation
100 lineinfile:
101 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
102 regexp: "^dashboard_enabled:.*"
103 line: "dashboard_enabled: false"
104
Fatih Degirmenci41873702019-04-08 22:24:18 +0000105# enable creation of kubeconfig on localhost for all the scenarios using kubespray
106- name: Enable creation of kubeconfig on localhost
107 lineinfile:
108 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml"
109 regexp: "^# kubeconfig_localhost:.*"
110 line: "kubeconfig_localhost: true"
111
Fatih Degirmenci40387d22019-05-21 11:36:10 +0200112# set k8s version to install
113- name: Set k8s version to '{{ kubernetes_version }}'
114 lineinfile:
115 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml"
116 regexp: "^kube_version:.*"
117 line: "kube_version: {{ kubernetes_version }}"
118
Fatih Degirmenci0f7feaf2019-05-28 14:21:20 +0200119# set helm version to install
120- name: Set helm version to '{{ helm_version }}'
121 lineinfile:
122 path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml"
123 regexp: "^helm_version:.*"
124 line: "helm_version: {{ helm_version }}"
125
Fatih Degirmencif2b36ac2019-04-01 23:28:50 +0000126# configure docker with iptables
127- name: Ensure docker daemon iptables option is set to true
128 lineinfile:
129 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/all/docker.yml"
130 regexp: "^docker_iptables_enabled:.*"
131 line: "docker_iptables_enabled: true"
132
Sriram Yagnaraman39cddd52019-10-11 15:04:45 +0200133- name: Check if KUBE_FEATURE_GATES is set
134 set_fact:
135 kube_feature_gates: []
136 feature_gate_list: "{{ lookup('env', 'KUBE_FEATURE_GATES') }}"
137
138- name: Setup feature gates list
139 set_fact:
140 kube_feature_gates: "{{ kube_feature_gates + [feature] }}"
141 with_items: "{{ feature_gate_list.split(',') }}"
142 loop_control:
143 loop_var: feature
144 when: feature_gate_list | length > 0
145
Sriram Yagnaraman7de7c952019-10-02 17:20:21 +0200146- name: Populate extra variables
147 template:
148 src: kubespray-extra-vars.yml.j2
149 dest: "{{ config_path }}/kubespray-extra-vars.yml"
150
Fatih Degirmenciccc68892019-02-27 09:16:45 +0000151# vim: set ts=2 sw=2 expandtab: