Dynamic kubelet is deprecated since k8s 1.24 thus to use distributed host config file instead
---
- name: "Playing with Ansible and Git"
hosts: localhost
connection: local
tasks:
- name: "Example1: Validate if a String or line is present in the file"
become: yes
become_user: root
tags: example1
lineinfile:
path: /var/lib/kubelet/config.yaml
regexp: "{{ item.regexp }}"
line: "{{ item.line }}"
loop:
- regexp: '^containerLogMaxSize'
line: "containerLogMaxSize: 50Mi"
- regexp: '^containerLogMaxFiles'
line: "containerLogMaxFiles: 5"
notify: Restart kubelet
register: example1out
- debug:
var: example1out
handlers:
- name: Restart kubelet
ansible.builtin.systemd:
name: kubelet
state: restarted