Skip to content

Commit

Permalink
Document No hosts matched the subscripted pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
ssbarnea committed Sep 21, 2022
1 parent f1ecf22 commit f731ce4
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/ansiblelint/_internal/internal_error.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,13 @@ them to the `exclude_paths`.
hosts: localhost
tasks: []
```

## ERROR! No hosts matched the subscripted pattern

If you see this error, it means that you tried to index a host group variable
that is using an index above its size.

Instead of doing something like `hosts: all[1]` which assumes that you have
at least two hosts in your current inventory, you better write something like
`hosts: "{{ all[1] | default([]) }}`, which is safe and do not produce runtime
errors. Use safe fallbacks to make your code more resilient.

0 comments on commit f731ce4

Please sign in to comment.