--- - name: "how to use block" hosts: ansible.debian ansible.ubuntu tasks: - name: "install nginx" # Ce qui est prévu block: - name: "install nginx" ansible.builtin.apt: name: nginx state: present - name: configure nginx template: src: nginx.conf.j2 dest: /etc/nginx/nginx.conf - name: restart nginx ansible.builtin.service: name: nginx state: restarted # Ce qui est prévu en cas d’erreur rescue: - name: remove nginx conf file ansible.builtin.file: path: /etc/nginx/nginx.conf state: absent - name: remove nginx ansible.builtin.apt: name: nginx state: absent # Dans tous les cas always: - name: display playbook finished message ansible.builtin.debug: msg: 'your play was played :)' # Commun pour toutes les tâches become: yes