---
- name: Install docker-ce (centos) via amazon-linux-extras packages
  shell: "amazon-linux-extras install docker -y"

- name: Ensure Python pip packages are installed
  pip:
    name: "{{ item }}"
  with_items:
    - boto
    - boto3
    - docker-compose

#- 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
