Différences
Ci-dessous, les différences entre deux révisions de la page.
| public:ansible [2024/10/25 15:06] – [Vérification SYNTAX et Test du Playbook] vincent1890 | public:ansible [2024/10/25 15:13] (Version actuelle) – modification externe 127.0.0.1 | ||
|---|---|---|---|
| Ligne 168: | Ligne 168: | ||
| ansible-playbook -i [Nom-Fichier-Inventaire].yml [Nom-Fichier-Playbook].yml --syntax-check | ansible-playbook -i [Nom-Fichier-Inventaire].yml [Nom-Fichier-Playbook].yml --syntax-check | ||
| - | Vérifier ce que la commande donnerait pour **TOUS** ou le **groupe [Nom-Groupe** (Ex: deb_master) **]** seulement | + | Vérifier ce que la commande donnerait pour **TOUS** ou le **groupe [Nom-Groupe** (Ex: <color #ed1c24>deb_master</ |
| ansible-playbook -i [Nom-Fichier-Inventaire].yml [Nom-Fichier-Playbook].yml -C -l all | ansible-playbook -i [Nom-Fichier-Inventaire].yml [Nom-Fichier-Playbook].yml -C -l all | ||
| ou | ou | ||
| Ligne 235: | Ligne 235: | ||
| ---- | ---- | ||
| + | |||
| + | === Création d'un Playbook (regroupe plusieurs actions avec un handlers) === | ||
| <file Bash Playbook_Multi_SSH-Config.yml> | <file Bash Playbook_Multi_SSH-Config.yml> | ||
| Ligne 282: | Ligne 284: | ||
| name: ssh | name: ssh | ||
| state: restarted | state: restarted | ||
| + | </ | ||
| + | |||
| + | ou alors la meme chose avec un playbook plus simpliste \\ | ||
| + | |||
| + | <file Bash Playbook_Multi_SSH-Config_2.yml> | ||
| + | --- | ||
| + | - name: Playbook pour sécuriser SSH et installer BIND v2 | ||
| + | hosts: all | ||
| + | become: true | ||
| + | |||
| + | tasks: | ||
| + | # Secure SSH : | ||
| + | - name: sec ssh | ||
| + | blockinfile: | ||
| + | path: / | ||
| + | state: present | ||
| + | backup: yes | ||
| + | insertafter: | ||
| + | block: | | ||
| + | Match User ansible | ||
| + | AllowUsers [email protected] | ||
| + | PasswordAuthentication no | ||
| + | - name: restart ssh | ||
| + | service: | ||
| + | name: sshd | ||
| + | state: restarted | ||
| + | |||
| + | # Disable login with password : | ||
| + | - name: disable login password | ||
| + | user: | ||
| + | name: ansible | ||
| + | password: " | ||
| + | |||
| + | # Install Bind sur les deux serveur : | ||
| + | - name: Install Bind | ||
| + | apt: | ||
| + | update_cache: | ||
| + | name: bind9 | ||
| + | state: present | ||
| </ | </ | ||