fix(kb/ansible): improve on best practices

This commit is contained in:
Michele Cereda
2024-09-15 12:55:41 +02:00
parent 855aa588ba
commit 304a49d435

View File

@@ -1082,12 +1082,10 @@ Or even edit their content with `ansible-vault edit 'path/to/file'`.
## Best practices
- Tag all tasks.
- Define tasks so that playbook runs will not fail just because a task depends on another.
- Provide ways to manually feed values to dependent tasks so a run can start from there or only use tagged tasks, e.g.
by using variables that can be overridden in the command line.
- If using other systems to maintain a canonical list of systems in one's infrastructure, consider using dynamic
inventories.
- Tag **all** tasks somehow.
- Define tasks so that playbook runs will **not** fail just because one task depends on another.
- Provide ways to **manually** feed values to dependent tasks so that runs can start from there or only use tagged
tasks, e.g. by using variables that can be overridden in the command line.
- Consider using `blocks` to group tasks logically.
- Keep debugging messages but set them to run only at higher verbosity:
@@ -1100,6 +1098,11 @@ Or even edit their content with `ansible-vault edit 'path/to/file'`.
verbosity: 3
```
- When **replacing** resources, if possible, make sure the replacement is set correctly **before** deleting the
original.
- If using other systems to maintain a canonical list of systems in one's infrastructure, consider using dynamic
inventories.
## Troubleshooting
### Print all known variables