summaryrefslogtreecommitdiff
path: root/roles/kubernetes/base/tasks/main.yml
blob: 731be48b4b3559321e2b806d16d9965956c47594 (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
---
- name: prepare /var/lib/kubelet as LVM
  when: kubelet_lvm is defined
  import_tasks: lvm.yml

- name: prepare /var/lib/kubelet as ZFS dataset
  when: kubelet_zfs is defined
  import_tasks: zfs.yml

- name: install apt https transport
  apt:
    name: apt-transport-https
    state: present

- name: add repository key
  copy:
    src: apt-key.gpg
    dest: /etc/apt/trusted.gpg.d/kubernetes.gpg
  notify: update apt cache

- name: add repository entry
  copy:
    content: |
      deb https://apt.kubernetes.io/ kubernetes-xenial main
    dest: /etc/apt/sources.list.d/kubernetes.list
  notify: update apt cache

- name: update apt cache
  meta: flush_handlers

- name: install kubelet and utils
  apt:
    name:
    - "kubelet{% if kubernetes.pkg_version is defined %}={{ kubernetes.pkg_version }}{% endif %}"
    - cri-tools
    - bridge-utils
    state: present

- name: disable automatic upgrades for kubelet
  when: kubernetes.pkg_version is defined
  loop:
  - kubelet
  dpkg_selections:
    name: "{{ item }}"
    selection: hold

- name: configure crictl to use containerd
  loop:
    - zsh
    - bash
  blockinfile:
    path: "/root/.{{ item }}rc"
    create: yes
    marker: "### {mark} ANSIBLE MANAGED BLOCK for crictl ###"
    content: |
      {% if kubernetes_container_runtime == 'containerd' %}
      alias crictl="crictl --runtime-endpoint unix:///run/containerd/containerd.sock"
      {% endif %}
      {% if item == 'zsh' %}
      ## TODO: see https://github.com/kubernetes-sigs/cri-tools/issues/435
      autoload -U +X bashcompinit && bashcompinit
      {% endif %}
      source <(crictl completion)

- 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: "!"