blob: b754e248d649f4af4b5c6303c9d295da001d3465 [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
Your Nameddc40f82019-12-12 14:02:40 +000024 when: not offline_deployment|bool
Fatih Degirmenciccc68892019-02-27 09:16:45 +000025
26- name: Clone kubespray repository and checkout '{{ kubespray_version }}'
27 git:
28 repo: "{{ kubespray_git_url }}"
29 dest: "{{ engine_cache }}/repos/kubespray"
30 version: "{{ kubespray_version }}"
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000031 force: true
Wenqing Gufa739512019-08-21 09:29:23 +000032 environment: "{{ idf.proxy_settings | default({}) }}"
Your Nameddc40f82019-12-12 14:02:40 +000033 when: not offline_deployment|bool
Fatih Degirmenciccc68892019-02-27 09:16:45 +000034
35# TODO: some stuff below could and perhaps should be pushed into the scenario
36# it is put here to make basic installation work without complexities
37- name: Put initial structure in place
38 synchronize:
39 src: "{{ engine_cache }}/repos/kubespray/inventory/sample/"
40 dest: "{{ engine_cache }}/repos/kubespray/inventory/engine"
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000041 recursive: true
42 delete: true
Fatih Degirmenciccc68892019-02-27 09:16:45 +000043
Fatih Degirmenci3646fcd2019-06-12 16:21:11 +020044# place generated kubespray inventory to kubespray/inventory/engine
45- name: Place inventory
46 copy:
Fatih Degirmenci71e0ebc2020-01-09 07:26:08 +000047 src: "{{ inventory_path }}/inventory.ini"
Fatih Degirmenci3646fcd2019-06-12 16:21:11 +020048 dest: "{{ engine_cache }}/repos/kubespray/inventory/engine/inventory.ini"
49 mode: 0644
50
Wenqing Gufa739512019-08-21 09:29:23 +000051# update proxy if settings are provided
52- name: Update proxy settings in all.yml
53 lineinfile:
54 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/all/all.yml"
55 regexp: "^[#\\s]*{{ item.name }}"
56 line: "{{ item.name }}: {{ item.value }}"
57 with_items:
Fatih Degirmenci87c986c2020-01-12 22:35:53 +000058 - {name: 'http_proxy', value: '{{ idf.proxy_settings.http_proxy }}'}
59 - {name: 'https_proxy', value: '{{ idf.proxy_settings.https_proxy }}'}
60 - {name: 'no_proxy', value: '{{ idf.proxy_settings.no_proxy }}'}
Wenqing Gufa739512019-08-21 09:29:23 +000061 when:
62 idf.proxy_settings is defined
63
Wenqing Gu3d802212019-04-18 08:28:24 +020064# update ControlPersist to 60m to inline with max time
65- name: Update ControlPersist in ansible config
66 lineinfile:
67 path: "{{ engine_cache }}/repos/kubespray/ansible.cfg"
68 regexp: "^ssh_args.*"
69 line: "ssh_args = -o ControlMaster=auto -o ControlPersist=60m -o ConnectionAttempts=100 -o UserKnownHostsFile=/dev/null"
70
Fatih Degirmenci51a4f882019-03-19 17:35:15 +000071# enable helm for all the scenarios using kubespray
72- name: Enable helm
73 lineinfile:
74 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
75 regexp: "^helm_enabled:.*"
76 line: "helm_enabled: true"
77
Sriram Yagnaraman82bd8722019-11-21 16:08:48 +010078# enable metrics server for all the scenarios using kubespray
79- name: Enable metrics server
80 lineinfile:
81 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
82 regexp: "^metrics_server_enabled:.*"
83 line: "metrics_server_enabled: true"
84
85# enable metrics server metric resolution
86- name: Enable metrics server resolution
87 lineinfile:
88 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
89 regexp: "^#metrics_server_metric_resolution:.*"
90 line: "metrics_server_metric_resolution: 60s"
91
92# enable metrics server metric resolution
93- name: Enable metrics_server_kubelet_preferred_address_types
94 lineinfile:
95 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
96 regexp: "^#metrics_server_kubelet_preferred_address_types:.*"
97 line: "metrics_server_kubelet_preferred_address_types: 'InternalIP'"
98
Ignacio Pascual1f4a35e2020-02-13 13:56:48 +010099# disable kubernetes dashboard installation. It does not work with versions >=v1.16.0
100# https://github.com/kubernetes-sigs/kubespray/issues/5347
101- name: Disable kubernetes dashboard installation
102 lineinfile:
103 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml"
104 regexp: "^dashboard_enabled:.*"
105 line: "dashboard_enabled: false"
106
Fatih Degirmenci41873702019-04-08 22:24:18 +0000107# enable creation of kubeconfig on localhost for all the scenarios using kubespray
108- name: Enable creation of kubeconfig on localhost
109 lineinfile:
110 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml"
111 regexp: "^# kubeconfig_localhost:.*"
112 line: "kubeconfig_localhost: true"
113
Fatih Degirmenci40387d22019-05-21 11:36:10 +0200114# set k8s version to install
115- name: Set k8s version to '{{ kubernetes_version }}'
116 lineinfile:
117 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml"
118 regexp: "^kube_version:.*"
119 line: "kube_version: {{ kubernetes_version }}"
120
Fatih Degirmenci0f7feaf2019-05-28 14:21:20 +0200121# set helm version to install
122- name: Set helm version to '{{ helm_version }}'
123 lineinfile:
124 path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml"
125 regexp: "^helm_version:.*"
126 line: "helm_version: {{ helm_version }}"
127
Fatih Degirmencif2b36ac2019-04-01 23:28:50 +0000128# configure docker with iptables
129- name: Ensure docker daemon iptables option is set to true
130 lineinfile:
131 path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/all/docker.yml"
132 regexp: "^docker_iptables_enabled:.*"
133 line: "docker_iptables_enabled: true"
134
Sriram Yagnaraman39cddd52019-10-11 15:04:45 +0200135- name: Check if KUBE_FEATURE_GATES is set
136 set_fact:
137 kube_feature_gates: []
138 feature_gate_list: "{{ lookup('env', 'KUBE_FEATURE_GATES') }}"
139
140- name: Setup feature gates list
141 set_fact:
142 kube_feature_gates: "{{ kube_feature_gates + [feature] }}"
143 with_items: "{{ feature_gate_list.split(',') }}"
144 loop_control:
145 loop_var: feature
146 when: feature_gate_list | length > 0
147
Sriram Yagnaraman7de7c952019-10-02 17:20:21 +0200148- name: Populate extra variables
149 template:
150 src: kubespray-extra-vars.yml.j2
151 dest: "{{ config_path }}/kubespray-extra-vars.yml"
152
Your Nameddc40f82019-12-12 14:02:40 +0000153# Ensure proper configuration for offline deployment
154- include_tasks: prepare-offline.yml
155 when: offline_deployment|bool
156
157# Enable file download for offline "Fetch dependency mode"
158- name: Enable one time file download in master node
159 lineinfile:
160 path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml"
161 regexp: "^download_run_once:.*"
162 line: "download_run_once: true"
163 when: offline_dependencies|bool
164
165# Use a fake docker repository to overcome apt-cacher-ng limitation with https
166- name: Configure docker repo to use jumphost apt proxy
167 lineinfile:
168 path: "{{ engine_cache }}/repos/kubespray/roles/container-engine/docker/defaults/main.yml"
169 regexp: "^docker_ubuntu_repo_base_url:.*"
170 line: 'docker_ubuntu_repo_base_url: "http://nordix.download.docker.com/linux/ubuntu"'
171 when: offline_dependencies|bool or offline_deployment|bool
172
Fatih Degirmenciccc68892019-02-27 09:16:45 +0000173# vim: set ts=2 sw=2 expandtab: