df7334ce1c5c28c3593aab37cf889157d2ed876f
[yardstick.git] / ansible / roles / init_kubeadm / tasks / main.yml
1 # Copyright (c) 2018-2019 Intel Corporation.
2 #
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
6 #
7 #      http://www.apache.org/licenses/LICENSE-2.0
8 #
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.
14 ---
15 - name: Disable swap
16   command: swapoff -a
17   ignore_errors: true
18
19 - name: Reset Kubernetes cluster
20   command: kubeadm reset
21
22 - name: Clean Kubernetes directories (w/o removing the folder itself)
23   shell: rm -fr {{ item }}/*
24   with_items:
25     - /etc/kubernetes
26     - /var/lib/cni
27     - /etc/cmk
28
29 - name: Create Multus CNI plugin dir
30   file: path=/etc/cni/net.d state=directory
31
32 - name: Configure Multus CNI plugin
33   template: src=10-multus-cni.conf.j2 dest=/etc/cni/net.d/10-multus-cni.conf owner=root mode=0644
34
35 - name: Change default kubelet cluster dns IP
36   lineinfile:
37     path: /etc/systemd/system/kubelet.service.d/10-kubeadm.conf
38     regexp: '^(.*)--cluster-dns=([0-9\.]*)( +.*)$'
39     line: '\1--cluster-dns={{ kubelet_cluster_dns_ip }}\3'
40     backrefs: yes
41     backup: yes
42
43 - name: Systemd daemon reload
44   command: systemctl daemon-reload
45
46 - name: Restart kubelet
47   service: name=kubelet state=restarted
48
49 - name: Initialize kubeadm
50   include: kubeadm.yml
51
52 - name: Create CMK Kubernetes resources
53   command: kubectl create -f {{ item }}
54   with_items:
55     - "{{ cmk_rbc_rules_url }}"
56     - "{{ cmk_serviceaccount }}"
57
58 - name: Create Kubernetes resources
59   include: kubectl.yml
60   with_items:
61     - crd-network.yaml
62     - net-flannel.yaml
63     - roles.yaml
64     - kube-flannel.yaml
65     - cmk-init-pod.yaml
66
67 - name: Create a ClusterRoleBinding for a particular ClusterRole
68   command: >
69            kubectl create clusterrolebinding multus-node-{{ ansible_hostname }}
70            --clusterrole=multus-crd-overpowered --user=system:node:{{ ansible_hostname }}