Group Tasks with block
Bundle tasks for shared behavior.
Tasks That Belong Together
Some tasks naturally form a unit. The block keyword groups several tasks so they can share settings and behavior. 📦
What a block Looks Like
A block is a list of tasks nested under one block key. They run top to bottom, just like normal tasks.
- name: Set up the app
block:
- name: Install package
ansible.builtin.package:
name: nginx
- name: Start service
ansible.builtin.service:
name: nginx
state: started