From 304a49d435740e2532118d60410dc6d277d48ccc Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Sun, 15 Sep 2024 12:55:41 +0200 Subject: [PATCH] fix(kb/ansible): improve on best practices --- knowledge base/ansible.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/knowledge base/ansible.md b/knowledge base/ansible.md index e74cbfc..94d8cfe 100644 --- a/knowledge base/ansible.md +++ b/knowledge base/ansible.md @@ -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