Fatih Degirmenci | ccc6889 | 2019-02-27 09:16:45 +0000 | [diff] [blame] | 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: 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 Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 30 | force: true |
Wenqing Gu | fa73951 | 2019-08-21 09:29:23 +0000 | [diff] [blame] | 31 | environment: "{{ idf.proxy_settings | default({}) }}" |
Fatih Degirmenci | ccc6889 | 2019-02-27 09:16:45 +0000 | [diff] [blame] | 32 | |
| 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 Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 39 | recursive: true |
| 40 | delete: true |
Fatih Degirmenci | ccc6889 | 2019-02-27 09:16:45 +0000 | [diff] [blame] | 41 | |
Fatih Degirmenci | 3646fcd | 2019-06-12 16:21:11 +0200 | [diff] [blame] | 42 | # place generated kubespray inventory to kubespray/inventory/engine |
| 43 | - name: Place inventory |
| 44 | copy: |
Fatih Degirmenci | 71e0ebc | 2020-01-09 07:26:08 +0000 | [diff] [blame] | 45 | src: "{{ inventory_path }}/inventory.ini" |
Fatih Degirmenci | 3646fcd | 2019-06-12 16:21:11 +0200 | [diff] [blame] | 46 | dest: "{{ engine_cache }}/repos/kubespray/inventory/engine/inventory.ini" |
| 47 | mode: 0644 |
| 48 | |
Wenqing Gu | fa73951 | 2019-08-21 09:29:23 +0000 | [diff] [blame] | 49 | # 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 Degirmenci | 87c986c | 2020-01-12 22:35:53 +0000 | [diff] [blame] | 56 | - {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 Gu | fa73951 | 2019-08-21 09:29:23 +0000 | [diff] [blame] | 59 | when: |
| 60 | idf.proxy_settings is defined |
| 61 | |
Wenqing Gu | 3d80221 | 2019-04-18 08:28:24 +0200 | [diff] [blame] | 62 | # 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 Degirmenci | 51a4f88 | 2019-03-19 17:35:15 +0000 | [diff] [blame] | 69 | # 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 Yagnaraman | 82bd872 | 2019-11-21 16:08:48 +0100 | [diff] [blame] | 76 | # 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 Pascual | 1f4a35e | 2020-02-13 13:56:48 +0100 | [diff] [blame^] | 97 | # 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 Degirmenci | 4187370 | 2019-04-08 22:24:18 +0000 | [diff] [blame] | 105 | # 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 Degirmenci | 40387d2 | 2019-05-21 11:36:10 +0200 | [diff] [blame] | 112 | # 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 Degirmenci | 0f7feaf | 2019-05-28 14:21:20 +0200 | [diff] [blame] | 119 | # 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 Degirmenci | f2b36ac | 2019-04-01 23:28:50 +0000 | [diff] [blame] | 126 | # 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 Yagnaraman | 39cddd5 | 2019-10-11 15:04:45 +0200 | [diff] [blame] | 133 | - 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 Yagnaraman | 7de7c95 | 2019-10-02 17:20:21 +0200 | [diff] [blame] | 146 | - name: Populate extra variables |
| 147 | template: |
| 148 | src: kubespray-extra-vars.yml.j2 |
| 149 | dest: "{{ config_path }}/kubespray-extra-vars.yml" |
| 150 | |
Fatih Degirmenci | ccc6889 | 2019-02-27 09:16:45 +0000 | [diff] [blame] | 151 | # vim: set ts=2 sw=2 expandtab: |