---
- name: Add docker script
  command: curl -fsSL https://get.docker.com -o /root/get-docker.sh

- name: install docker
  command: sh /root/get-docker.sh

- name: Create docker configuration directory
  file:
    path: /etc/docker
    state: directory

#- name: Install required packages
#  yum:
#    name: ['docker-ce']
#    state: present
#  notify:
#    - Reload systemd configuration
#    - Restart docker service

- name: Configure docker
  template:
    src: daemon.json.j2
    dest: /etc/docker/daemon.json
  notify:
    - Reload systemd configuration
    - Restart docker service

#- name: Delete containerd config
#  file:
#    path: /etc/containerd/config.toml
#    state: absent
#  notify:
#    - Restart containerd service

- meta: flush_handlers

- name: Enable docker service
  service:
    name: docker
    enabled: True
    state: started
   
- name: Add kubernetes yum repository
  ansible.builtin.yum_repository:
    name: kubernetes
    description: kubernetes
    baseurl: https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
    enabled: 1
    gpgcheck: 1
    gpgkey: https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg

- name: Install kubernetes utils
  ansible.builtin.yum:
    name: ['kubelet-{{kubernetes_version}}','kubeadm-{{kubernetes_version}}','kubectl-{{kubernetes_version}}']
    exclude: kubernetes
  notify:
    - Reload systemd configuration 