I have a bunch of servers that have four physical drives on them (/dev/sda, sdb, sdc, and sdd). sda has the OS installed on it.
I need to format each drive except sda. I
Your tasks can be as simple as this...
- stat: path: /dev/{{item}}1 with_items: ansible_devices.keys() when: item != 'sda' register: stats - command: /sbin/parted -s /dev/{{item.item}} mklabel gpt with_items: stats.results when: item.stat | default(false) and item.stat.exists