geerlingguy / geerlingguy/ansible-for-devops

block doesn't like loops/with_

Open
#467 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Python
Stars
9.9k
Forks
3.8k
PR merge metrics
No merged PRs in 30d

Description

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](https://docs.ansible.com/ansible/latest/user_guide/playbooks_blocks.html):

> "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

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with page 120 and the linked blocks documentation, then compare the quoted guidance with the reported block and loop example. Determine whether the documentation needs clarification about loop support on blocks and what users should expect; done means the limitation and relevant guidance are clear.

Written by the indexing model from the issue text.

Assessment

Tech stack
ansible
Domain
devops, documentation
Issue type
Documentation
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.