--- - name: create direcotry for encryption config file: name: /etc/kubernetes/encryption state: directory mode: 0700 - name: install encryption config template: src: encryption-config.j2 dest: /etc/kubernetes/encryption/config mode: 0600 - name: install primary control-plane node when: "'_kubernetes_primary_controlplane_node_' in group_names" include_tasks: primary.yml - name: install secondary control-plane nodes when: "'_kubernetes_primary_controlplane_node_' not in group_names" include_tasks: secondary.yml - name: check if control-plane node is tainted (1/2) command: "kubectl --kubeconfig /etc/kubernetes/admin.conf get node {{ kubernetes_node_name }} -o json" check_mode: no register: kubectl_get_node changed_when: False - name: check if control-plane node is tainted (2/2) set_fact: kube_node_taints: "{% set node_info = kubectl_get_node.stdout | from_json %}{%if node_info.spec.taints is defined %}{{ node_info.spec.taints | map(attribute='key') | list }}{% endif %}" - name: remove control-plane taint from node when: - not kubernetes.dedicated_controlplane_nodes - "'node-role.kubernetes.io/control-plane' in kube_node_taints" command: "kubectl --kubeconfig /etc/kubernetes/admin.conf taint nodes {{ kubernetes_node_name }} node-role.kubernetes.io/control-plane-" - name: add control-plane taint to node when: - kubernetes.dedicated_controlplane_nodes - "'node-role.kubernetes.io/control-plane' not in kube_node_taints" command: "kubectl --kubeconfig /etc/kubernetes/admin.conf taint nodes {{ kubernetes_node_name }} node-role.kubernetes.io/control-plane='':NoSchedule" - name: prepare kubectl (1/2) file: name: /root/.kube state: directory - name: prepare kubectl (2/2) file: dest: /root/.kube/config src: /etc/kubernetes/admin.conf state: link - name: add kubectl completion config for shells loop: - zsh - bash blockinfile: path: "/root/.{{ item }}rc" create: yes marker: "### {mark} ANSIBLE MANAGED BLOCK for kubectl ###" content: | source <(kubectl completion {{ item }}) - name: install k9s apt: name: k9s state: present - name: add k9s completion config for shells loop: - zsh - bash blockinfile: path: "/root/.{{ item }}rc" create: yes marker: "### {mark} ANSIBLE MANAGED BLOCK for k9s ###" content: | source <(k9s completion {{ item }})