| --- |
| # ============LICENSE_START======================================================= |
| # Copyright (C) 2019 The Nordix Foundation. All rights reserved. |
| # ================================================================================ |
| # Licensed under the Apache License, Version 2.0 (the "License"); |
| # you may not use this file except in compliance with the License. |
| # You may obtain a copy of the License at |
| # |
| # http://www.apache.org/licenses/LICENSE-2.0 |
| # |
| # Unless required by applicable law or agreed to in writing, software |
| # distributed under the License is distributed on an "AS IS" BASIS, |
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| # See the License for the specific language governing permissions and |
| # limitations under the License. |
| # |
| # SPDX-License-Identifier: Apache-2.0 |
| # ============LICENSE_END========================================================= |
| |
| - name: Remove existing files and directories |
| file: |
| path: "{{ engine_cache }}/repos/kubespray" |
| state: absent |
| |
| - name: Clone kubespray repository and checkout '{{ kubespray_version }}' |
| git: |
| repo: "{{ kubespray_git_url }}" |
| dest: "{{ engine_cache }}/repos/kubespray" |
| version: "{{ kubespray_version }}" |
| force: yes |
| environment: |
| http_proxy: "{{ lookup('env','http_proxy') }}" |
| https_proxy: "{{ lookup('env','https_proxy') }}" |
| no_proxy: "{{ lookup('env','no_proxy') }}" |
| |
| # TODO: some stuff below could and perhaps should be pushed into the scenario |
| # it is put here to make basic installation work without complexities |
| - name: Put initial structure in place |
| synchronize: |
| src: "{{ engine_cache }}/repos/kubespray/inventory/sample/" |
| dest: "{{ engine_cache }}/repos/kubespray/inventory/engine" |
| recursive: yes |
| delete: yes |
| |
| # update ControlPersist to 60m to inline with max time |
| - name: Update ControlPersist in ansible config |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/ansible.cfg" |
| regexp: "^ssh_args.*" |
| line: "ssh_args = -o ControlMaster=auto -o ControlPersist=60m -o ConnectionAttempts=100 -o UserKnownHostsFile=/dev/null" |
| |
| # enable helm for all the scenarios using kubespray |
| - name: Enable helm |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/addons.yml" |
| regexp: "^helm_enabled:.*" |
| line: "helm_enabled: true" |
| |
| # enable creation of kubeconfig on localhost for all the scenarios using kubespray |
| - name: Enable creation of kubeconfig on localhost |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml" |
| regexp: "^# kubeconfig_localhost:.*" |
| line: "kubeconfig_localhost: true" |
| |
| # set k8s version to install |
| - name: Set k8s version to '{{ kubernetes_version }}' |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/k8s-cluster/k8s-cluster.yml" |
| regexp: "^kube_version:.*" |
| line: "kube_version: {{ kubernetes_version }}" |
| |
| # set helm version to install |
| - name: Set helm version to '{{ helm_version }}' |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/roles/download/defaults/main.yml" |
| regexp: "^helm_version:.*" |
| line: "helm_version: {{ helm_version }}" |
| |
| # TODO: reuse of bifrost dynamic inventory is only valid for the cases that use |
| # bifrost for provisioning so this needs fixing and we could perhaps switch to |
| # our own inventory, dynamic or static. |
| - name: Place bifrost_inventory.py in Kubespray inventory |
| file: |
| src: "{{ engine_cache }}/repos/bifrost/playbooks/inventory/bifrost_inventory.py" |
| dest: "{{ engine_cache }}/repos/kubespray/inventory/engine/bifrost_inventory.py" |
| state: link |
| |
| # configure docker with iptables |
| - name: Ensure docker daemon iptables option is set to true |
| lineinfile: |
| path: "{{ engine_cache }}/repos/kubespray/inventory/engine/group_vars/all/docker.yml" |
| regexp: "^docker_iptables_enabled:.*" |
| line: "docker_iptables_enabled: true" |
| |
| # vim: set ts=2 sw=2 expandtab: |