---
- name: Test Stuff
  hosts: docker
  tasks:
    - name: Create directories
      file:
        path: '{{ item }}'
        state: directory
        owner: root
        group: root
        mode: '0750'
      loop:
        - '/var/lib/containerd'
        - '/var/lib/docker/volumes'
        - '/volumes'

    - name: Create Docker Logical Volume
      community.general.lvol:
        vg: data
        lv: docker
        size: 8G

    - name: Create Logical Volume 'vols'
      community.general.lvol:
        vg: data
        lv: vols
        size: 1G

    - name: Create Filesystem on docker
      community.general.filesystem:
        fstype: xfs
        dev: /dev/data/docker

    - name: Create Filesystem on vols
      community.general.filesystem:
        fstype: xfs
        dev: /dev/data/vols

    - name: Mount filesystems
      ansible.posix.mount:
        path: '{{ item.path }}'
        src: '{{ item.src }}'
        opts: '{{ item.opts }}'
        state: mounted
        fstype: "{{ item.fstype | default('xfs') }}"
      loop:
        - { path: '/var/lib/containerd', src: '/dev/data/docker', opts: 'noatime' }
        - { path: '/var/lib/docker/volumes', src: '/dev/data/vols', opts: 'noatime' }
        - { path: '/volumes', src: '/var/lib/docker/volumes', opts: 'bind', fstype: 'none' }


