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
22 - debug: var=ansible_host
24 - name: Disabling firewall for successfull k3s installation on CentOs
26 cmd: systemctl stop firewalld
27 when: ansible_facts['distribution'] == "CentOS" and result is failed
29 - name: install container-selinux
31 cmd: yum install -y container-selinux selinux-policy-base
32 when: ansible_facts['distribution'] == "CentOS" and result is failed
35 - name: install k3s-selinux-0.1.1-rc1.el7.noarch.rpm
37 cmd: rpm -i https://rpm.rancher.io/k3s-selinux-0.1.1-rc1.el7.noarch.rpm
38 when: ansible_facts['distribution'] == "CentOS" and result is failed
41 - name: get interface name
43 cmd: ip a |grep {{ ansible_host }} |awk '{print $NF}'
45 when: result is failed
49 cmd: curl -sfL https://get.k3s.io | sh -
50 when: result is failed
52 - name: create .kube dir
54 cmd: mkdir -p $HOME/.kube/
55 when: result is failed
57 - name: copy kubeconfig
59 cmd: cp /etc/rancher/k3s/k3s.yaml $HOME/.kube/config
60 when: result is failed