blob: 4e3aba4efe5ebc191943ce629ae8ca1533468952 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
|
---
- name: prepare /var/lib/kubelet as LVM
when: kubelet_lvm is defined
block:
- name: create logical volume
lvol:
vg: "{{ kubelet_lvm.vg }}"
lv: "{{ kubelet_lvm.lv }}"
size: "{{ kubelet_lvm.size }}"
- name: create filesystem
filesystem:
fstype: "{{ kubelet_lvm.fs }}"
dev: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}"
- name: mount filesytem
mount:
src: "/dev/mapper/{{ kubelet_lvm.vg | replace('-', '--') }}-{{ kubelet_lvm.lv | replace('-', '--') }}"
path: /var/lib/kubelet
fstype: "{{ kubelet_lvm.fs }}"
state: mounted
- name: install apt https transport
apt:
name: apt-transport-https
state: present
- name: add kubernetes apt key
apt_key:
data: "{{ lookup('file', 'kubernetes-apt-key.asc') }}"
state: present
- name: add kubernetes apt repo
apt_repository:
repo: deb http://apt.kubernetes.io/ kubernetes-xenial main
state: present
filename: kubernetes
- name: install basic kubernetes components
with_items:
- "kubelet{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
- "kubeadm{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
- "kubectl{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
apt:
name: "{{ item }}"
state: present
- name: disable automatic upgrades for kubernetes components
when: kubernetes.pkg_version is defined
with_items:
- kubelet
- kubeadm
- kubectl
dpkg_selections:
name: "{{ item }}"
selection: hold
- name: install kubelet config snippets
with_items:
- 20-dns.conf
- 50-extra.conf
template:
src: "{{ item }}.j2"
dest: "/etc/systemd/system/kubelet.service.d/{{ item }}"
notify: reload systemd
- name: add dummy group with gid 998
group:
name: app
gid: 998
- name: add dummy user with uid 998
user:
name: app
uid: 998
group: app
password: "!"
- name: add kubectl config for shells
with_items:
- zsh
- bash
blockinfile:
path: "/root/.{{ item }}rc"
create: yes
marker: "### {mark} ANSIBLE MANAGED BLOCK for kubectl ###"
content: |
source <(kubectl completion {{ item }})
|