- name: Install Docker on Alpine Linux
  hosts: all

  tasks:
    - name: Enable community packages
      ansible.builtin.lineinfile:
        path: /etc/apk/repositories
        regexp: '^#http://dl-cdn.alpinelinux.org/alpine/v3.18/community'
        line: 'http://dl-cdn.alpinelinux.org/alpine/v3.18/community'
        state: present

    - name: Update apk packages
      community.general.apk:
        update_cache: true

    - name: Install docker with apk
      community.general.apk:
        name: docker

    - name: Start docker service
      ansible.builtin.service:
        name: docker
        state: started
        enabled: true