--- - name: install kubeadm packages apt: name: - haproxy - haproxyctl - "kubeadm={{ kubernetes_version }}-00" - "kubectl={{ kubernetes_version }}-00" state: present force: yes ## TODO: remove force once the following changes are available ## https://github.com/ansible/ansible/pull/73629 or https://github.com/ansible/ansible/pull/72562 ## https://github.com/ansible/ansible/pull/74852 - 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 ## loading the modules temporarly because kubeadm will complain if they are not there # but i don't think it is necessary to make this persistent, also ignoring changes here - name: load module br_netfilter to satisfy kubeadm init/join modprobe: name: br_netfilter state: present changed_when: false - name: prepare network plugin include_tasks: "net_{{ kubernetes_network_plugin }}.yml"