block doesn't like loops/with_
After reading on page 120: "If you want to perform a series of tasks with one set of task parameters (e.g. with_- items, when, or become) applied, blocks are quite handy.", I tried this code:
- block:
- name: create Logical Volume
community.general.lvol:
vg: "{{ vgscan}}"
lv: "{{ item.key }}"
size: "{{ item.value }}"
- name: format the Logical Volume
community.general.filesystem:
dev: "/dev/mapper/{{ vgscan }}-{{ item.key }} "
fstype: xfs
opt: "-L {{ item.key }}"
when: "{{ item.key }} not in {{ lvscan.stdout }}"
#loop: "{{ gluster_vol_size|dict2items }}"
with_dictionary: "{{ gluster_vol_size }}"
and got back: ERROR! 'loop' is not a valid attribute for a Block
Digging in the documentation I found:
"All tasks in a block inherit directives applied at the block level. Most of what you can apply to a single task (with the exception of loops) can be applied at the block level, so blocks make it much easier to set data or directives common to the tasks."
Now I have to figure out how to do my loop.
Ted Miller
I don't mention in that section that loops are supported (and the example only shows examples of when applied to multiple tasks)—are you suggesting the section might need extra clarification?
Regarding this feature, see: https://github.com/ansible/ansible/issues/13262