Premier commit

This commit is contained in:
gitea committed 2026-10-18 16:41:04 +02:00
commit 518c7ab04b
49 files changed
+1120

No files matched your search

+43
View File
@@ -0,0 +1,43 @@
---
- 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