Your Name | ddc40f8 | 2019-12-12 14:02:40 +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 | # skip the default repo sync in helm init for offline deployments |
| 21 | # Helm 2 has hardcoded links to google repositories |
| 22 | - name: Skip default repository in helm |
| 23 | lineinfile: |
| 24 | path: "{{ engine_cache }}/repos/kubespray/roles/kubernetes-apps/helm/defaults/main.yml" |
| 25 | regexp: "^helm_skip_refresh:.*" |
| 26 | line: "helm_skip_refresh: true" |
| 27 | |
| 28 | - name: Disable file download |
| 29 | lineinfile: |
| 30 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 31 | regexp: "^download_run_once:.*" |
| 32 | line: "download_run_once: false" |
| 33 | |
| 34 | # Kubernetes version is hardcoded in the downloads section. This point to the wrong versions |
| 35 | # of kubeadm, kubectl and other packages stored in cache. |
| 36 | - name: Set k8s version to '{{ kubernetes_version }}' in downloads file |
| 37 | lineinfile: |
| 38 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 39 | regexp: "^kube_version:.*" |
| 40 | line: "kube_version: {{ kubernetes_version }}" |
| 41 | |
| 42 | # Downloads should take place in master node since has docker properly configure, i.e. |
| 43 | # the current user is either in the docker group or can do passwordless sudo. |
| 44 | - name: Ensure download happens in master node |
| 45 | lineinfile: |
| 46 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 47 | regexp: "^download_localhost:.*" |
| 48 | line: "download_localhost: false" |
| 49 | |
| 50 | - name: Enable the use of local cache |
| 51 | lineinfile: |
| 52 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 53 | regexp: "^download_force_cache:.*" |
| 54 | line: "download_force_cache: true" |
| 55 | |
| 56 | # This will overcome a bug in Kubespray that only loads Helm docker containers in |
| 57 | # the worker nodes, while some tasks needing those containers are executed in the |
| 58 | # master node. Thus, hitting the error image not found. |
| 59 | - name: Configure helm docker container to be loaded in master node |
| 60 | replace: |
| 61 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 62 | regexp: '(helm:(?:\n.*){1,8}-\s)kube.*(\n)' |
| 63 | replace: '\1k8s-cluster\2' |
| 64 | |
| 65 | # This will introduce the bug related to image names and docker default registry |
| 66 | - name: Enable local loading of docker images |
| 67 | lineinfile: |
| 68 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 69 | regexp: "^download_container:.*" |
| 70 | line: "download_container: true" |
| 71 | |
| 72 | # These two tasks will workaround a Kubespray bug that points to the wrong path |
| 73 | # when using docker images from the default registry. This causes the error of |
| 74 | # of image not found and timeout when trying to pull from Internet. |
| 75 | - name: Override wrong paths in cached docker images |
| 76 | block: |
| 77 | - name: Remove links to docker default registry |
| 78 | replace: |
| 79 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 80 | regexp: '\{\{ docker_image_repo \}\}/' |
| 81 | replace: '' |
| 82 | |
| 83 | - name: Fix path for nginx docker image |
| 84 | replace: |
| 85 | path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| 86 | regexp: 'library/nginx' |
| 87 | replace: 'nginx' |
| 88 | |
| 89 | # Docker engine apt key is usually added using url argument. The key is provided as a file, so |
| 90 | # the ansible task has to be modified accordingly. |
| 91 | - name: Modify apt_key task to use file argument instead of url |
| 92 | replace: |
| 93 | path: "{{ engine_cache }}/repos/kubespray/roles/container-engine/docker/tasks/main.yml" |
| 94 | regexp: '(\s)url:(\s.*key)' |
| 95 | replace: '\1file:\2' |
| 96 | |
| 97 | - name: Point docker repo to use the provided key file |
| 98 | lineinfile: |
| 99 | path: "{{ engine_cache }}/repos/kubespray/roles/container-engine/docker/defaults/main.yml" |
| 100 | regexp: "^docker_ubuntu_repo_gpgkey:.*" |
| 101 | line: 'docker_ubuntu_repo_gpgkey: "/tmp/docker.key"' |
| 102 | |
| 103 | # vim: set ts=2 sw=2 expandtab: |