--- tasks: - name: Set timezone to Europe/Paris community.general.timezone: name: Europe/Paris - name: maj fichier hosts ansible.builtin.blockinfile: path: /etc/hosts block: | 192.168.56.10 k8s-master 192.168.56.11 node-1 192.168.56.12 node-2 - name: Forwarding IPv4 and letting iptables see bridged traffic ansible.builtin.blockinfile: path: /etc/modules-load.d/k8s.conf create: yes block: | overlay br_netfilter - name: charge module overlay community.general.modprobe: state: present name: overlay - name: charge module overlay et br_netfilter community.general.modprobe: state: present name: br_netfilter - name: persistance des bridges ansible.builtin.blockinfile: path: /etc/sysctl.d/k8s.conf create: yes block: | net.bridge.bridge-nf-call-iptables = 1 net.bridge.bridge-nf-call-ip6tables = 1 net.ipv4.ip_forward = 1 - name: applique les parametres sysctl command: "sysctl --system" - name: Recupere get-docker get_url: url: "https://get.docker.com" dest: /tmp/get-docker.sh - name: lance get-docker - installe docker, containerd ... command: 'sh /tmp/get-docker.sh' - name: Add vagrant user to docker group user: name: vagrant group: docker - name: cree repertoire /etc/containerd file: path: /etc/containerd state: directory - name: genere config.toml (containerd) #command: "sudo containerd config default | sudo tee /etc/containerd/config.toml" shell: "containerd config default | tee /etc/containerd/config.toml" - name: configure cgroup driver pour systemd (config.toml) replace: path: "/etc/containerd/config.toml" regexp: 'SystemdCgroup = false' replace: 'SystemdCgroup = true' backup: yes - name: redemarre containerd service: name: containerd state: restarted enabled: yes - 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: Add an apt signing key for Kubernetes apt_key: url: https://packages.cloud.google.com/apt/doc/apt-key.gpg state: present - name: Adding apt repository for Kubernetes apt_repository: repo: deb https://apt.kubernetes.io/ kubernetes-xenial main state: present filename: kubernetes.list - name: Install Kubernetes binaries apt: name: "{{ packages }}" state: present update_cache: yes vars: packages: - kubelet - kubeadm - kubectl - name: Cree file kubelet ansible.builtin.file: path: /etc/default/kubelet state: touch - name: Configure node ip lineinfile: path: /etc/default/kubelet line: KUBELET_EXTRA_ARGS=--node-ip={{ node_ip }} create: yes - name: Restart kubelet service: name: kubelet daemon_reload: yes state: restarted # - name: nettoie config.toml # file: # path: /etc/containerd/config.toml # state: absent - name: redemarre containerd service: name: containerd state: restarted