summaryrefslogtreecommitdiff
path: root/roles/kubernetes/kubeadm/base/tasks/main.yml
blob: 2d2bd32421ba70c2c4feb9721a0f96861317898b (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
---
- name: install kubeadm packages
  apt:
    name:
      - haproxy
      - hatop
      - "kubeadm={{ kubernetes_version }}-00"
      - "kubectl={{ kubernetes_version }}-00"
    state: present
    force: yes

- name: disable automatic upgrades for kubeadm/kubectl
  loop:
    - kubeadm
    - kubectl
  dpkg_selections:
    name: "{{ item }}"
    selection: hold

- name: set kubelet node-ip
  when: kubernetes_overlay_node_ip is defined
  lineinfile:
    name: "/etc/default/kubelet"
    regexp: '^KUBELET_EXTRA_ARGS='
    line: 'KUBELET_EXTRA_ARGS=--node-ip={{ kubernetes_overlay_node_ip }}'
    create: yes

- name: add kubeadm config for shells
  loop:
    - zsh
    - bash
  blockinfile:
    path: "/root/.{{ item }}rc"
    create: yes
    marker: "### {mark} ANSIBLE MANAGED BLOCK for kubeadm ###"
    content: |
      source <(kubeadm completion {{ item }})

- name: configure haproxy
  template:
    src: haproxy.cfg.j2
    dest: /etc/haproxy/haproxy.cfg
  register: haproxy_config

- name: (re)start haproxy
  systemd:
    name: haproxy
    state: "{% if haproxy_config is changed %}restarted{% else %}started{% endif %}"
    enabled: yes

- name: add hatop config for shells
  loop:
    - zsh
    - bash
  blockinfile:
    path: "/root/.{{ item }}rc"
    create: yes
    marker: "### {mark} ANSIBLE MANAGED BLOCK for hatop ###"
    content: |
      alias hatop="hatop -s /var/run/haproxy/admin.sock"

# - name: prepare network plugin
#   include_tasks: "net_{{ kubernetes_network_plugin }}.yml"