1 # Copyright 2020 Huawei Technologies Co., Ltd.
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
16 - name: check whether k3s is already installed
24 msg: k3s is already present
25 when: result.stdout != ""
28 # yamllint disable rule:line-length
29 msg: Ignore Uninstall Log , k3s not installed continue with Installation
30 # yamllint disable rule:line-length
31 when: result.stdout == ""
34 msg: K3 Installation started on {{ ansible_facts['distribution'] }} MEP Node
36 - name: "INSTALL: Disabling firewall for successfull k3s installation on CentOs"
38 cmd: systemctl stop firewalld
39 when: ansible_facts['distribution'] == "CentOS" and result is failed
41 - name: "INSTALL: install container-selinux"
43 cmd: yum install -y container-selinux selinux-policy-base
44 when: ansible_facts['distribution'] == "CentOS" and result is failed
47 - name: "INSTALL: get interface name"
49 cmd: ip a |grep {{ ansible_host }} |awk '{print $NF}'
51 when: result is failed
53 # yamllint disable rule:line-length
54 - name: "INSTALL: install k3s"
56 cmd: curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="--node-ip={{ ansible_host }} --node-external-ip={{ ansible_host }} --bind-address={{ ansible_host }} --flannel-iface=eth0 --docker --no-deploy=servicelb --no-deploy=traefik --write-kubeconfig-mode 644 --kube-apiserver-arg="service-node-port-range=30000-36000"" sh -
57 when: result is failed
59 # yamllint disable rule:line-length
61 #- name: "INSTALL: install k3s"
63 # cmd: curl -sfL https://get.k3s.io | sh -
64 # when: result is failed
66 - name: "INSTALL: create .kube dir"
68 cmd: mkdir -p $HOME/.kube/
69 when: result is failed
71 - name: "INSTALL: copy kubeconfig"
73 cmd: cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
74 when: result is failed