diff --git a/knowledge base/acronyms and abbreviations.md b/knowledge base/acronyms and abbreviations.md index 76543de..99bd7f2 100644 --- a/knowledge base/acronyms and abbreviations.md +++ b/knowledge base/acronyms and abbreviations.md @@ -22,6 +22,7 @@ | BYOD | Bring Your Own Device | | | CD | Continuous Delivery | Continuous creation and testing of artifacts, ready to be deployed at the end of the process | | CD | Continuous Deployment | | +| CDN | Content Delivery Network | | | CI | Continuous Integration | | | CLI | Command Line Interface | | | CMS | Content Management System | | diff --git a/knowledge base/ansible.md b/knowledge base/ansible.md index 088e898..cfaac8f 100644 --- a/knowledge base/ansible.md +++ b/knowledge base/ansible.md @@ -13,6 +13,7 @@ 1. [Error handling](#error-handling) 1. [Using blocks](#using-blocks) 1. [Output formatting](#output-formatting) +1. [Handlers](#handlers) 1. [Roles](#roles) 1. [Get roles](#get-roles) 1. [Assign roles](#assign-roles) @@ -504,6 +505,46 @@ $ ANSIBLE_STDOUT_CALLBACK='json' ansible-playbook --inventory='localhost,' 'loca } ``` +## Handlers + +Blocks and `import_tasks` tend to make the handlers unreachable. + +Instead of using blocks, give the same listen string to all involved handlers: + +```diff +- - name: Block name +- block: +- - name: First task +- … +- - name: N-th task +- … ++ - name: First task ++ listen: Block name ++ … ++ - name: N-th task ++ listen: Block name ++ … +``` + +Instead of using `ìmport_tasks`, use `include_tasks`: + +```diff + - name: First task +- import_tasks: tasks.yml ++ include_tasks: tasks.yml +``` + +Handlers **can** notify other handlers: + +```yaml +- name: Configure Nginx + ansible.builtin.copy: … + notify: Restart Nginx + +- name: Restart Nginx + ansible.builtin.copy: … +``` + ## Roles ### Get roles diff --git a/snippets/ansible/tasks.yml b/snippets/ansible/tasks.yml index 2eeb99c..44f5b8c 100644 --- a/snippets/ansible/tasks.yml +++ b/snippets/ansible/tasks.yml @@ -402,7 +402,10 @@ register: instance_check retries: 12 delay: 15 - until: instance_check.instances[0].pending_modified_values.keys() | length > 0 + until: instance_check.instances[0].pending_modified_values.keys() | length == 0 + - name: Wait for AWS to realize some requests have been made + ansible.builtin.pause: + seconds: 60 - name: Send messages to Slack channels vars: