- hosts: all gather_facts: true vars: remount_state: ro remount_fs: - / - /usr - /opt tasks: - name: remount filesystems command: mount -oremount,{{ remount_state }} {{ item }} warn=false with_items: >- {{ ansible_mounts | selectattr('mount', 'in', remount_fs) | map(attribute='mount') | list }}