summaryrefslogtreecommitdiffstats
path: root/src/ansiblelint/_internal/internal_error.md
blob: 8db5e5e949c5d384f1f74fb39dc6376ab935dc4c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
# internal-error

This error can also be caused by internal bugs but also by custom rules.
Instead of just stopping tool execution, we generate the errors and continue
processing other files. This allows users to add this rule to their `warn_list`
until the root cause is fixed.

Keep in mind that once an `internal-error` is found on a specific file, no
other rules will be executed on that same file.

In almost all cases you will see more detailed information regarding the
original error or runtime exception that triggered this rule.

If these files are broken on purpose, like some test fixtures, you need to add
them to the `exclude_paths`.

## Problematic code

```yaml
---
- name: Some title {{ # <-- Ansible will not load this invalid jinja template
  hosts: localhost
  tasks: []
```

## Correct code

```yaml
---
- name: Some title
  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.