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