--- - name: install debian packages apt: pkg: "{{item}}" state: installed when: ansible_os_family=="Debian" with_items: - btrfs-tools - dosfstools - name: unmount filesystems mount: name: "{{ root_target_directory | default('') }}/{{ item.mount_point }}" state: unmounted with_items: "{{ filesystems[::-1] }}" when: filesystems_state == "unmounted" or filesystems_state == "formated" - name: filesystems filesystem: fstype: "{{ item.fstype }}" dev: "{{ item.device }}" opts: -U {{ item.uuid }} force: "{{ filesystems_state == 'formated' }}" with_items: "{{ filesystems }}" when: item.device is defined and ( filesystems_state == "mounted" or filesystems_state == "formated" ) and not item.fstype == "vfat" - name: format fat32 command: mkfs.fat -F32 {{ item.device }} with_items: "{{ filesystems }}" when: item.device is defined and filesystems_state == "formated" and item.fstype == "vfat" - name: mount filesystems mount: name: "{{ root_target_directory | default('') }}{{ root_target_directory is defined | ternary('/','') }}{{ item.mount_point }}" src: "{{ (item.uuid is defined | ternary('UUID=','')) + item.uuid | default(item.device) }}" fstype: "{{ item.fstype }}" opts: '{{ item.mount_options | default("defaults") }}' state: mounted with_items: "{{ filesystems }}" when: filesystems_state == "mounted" or filesystems_state == "formated"