# Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. # You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. --- - name: Load necessary modules modprobe: name: "{{ item }}" state: present with_items: - overlay - br_netfilter - name: Configure sysctl sysctl: name: "{{ item }}" value: "1" state: present loop: - net.ipv6.conf.default.disable_ipv6 - net.ipv6.conf.all.disable_ipv6 - net.ipv6.conf.lo.disable_ipv6 - net.bridge.bridge-nf-call-iptables - net.bridge.bridge-nf-call-ip6tables - net.ipv4.ip_forward ignore_errors: true # This is necessary when we run dnsmasq. # Otherwise, we get the error: # failed to create inotify: Too many open files - name: Configure number of inotify instances sysctl: name: "fs.inotify.max_user_instances" value: "256" state: present ignore_errors: true - name: Configure number of inotify instances sysctl: name: "{{ item }}" value: "0" state: present loop: - net.ipv4.conf.all.rp_filter - net.ipv4.conf.default.rp_filter ignore_errors: true - name: Remove swapfile from /etc/fstab mount: name: "{{ item }}" fstype: swap state: absent with_items: - swap - none - name: Disable swap command: swapoff -a when: ansible_swaptotal_mb > 0 - name: Install Kubernetes binaries apt: state: present update_cache: true allow_downgrade: true pkg: - "kubelet={{ kube_version }}" - "kubeadm={{ kube_version }}" - "kubectl={{ kube_version }}" - name: Restart kubelet service: name: kubelet daemon_reload: yes state: restarted - name: Configure resolv.conf template: src: files/resolv.conf dest: /etc/resolv.conf owner: root group: root mode: 0644 vars: nameserver_ip: "8.8.8.8" - name: Disable systemd-resolved service: name: systemd-resolved enabled: false state: stopped ignore_errors: true - name: Disable unbound service: name: unbound enabled: false state: stopped ignore_errors: true ...