Ajout de nouveaux playbooke et rôles
This commit is contained in:
parent
64c016d92c
commit
e8299dfc62
99 changed files with 1005 additions and 360 deletions
25
.gitignore
vendored
Normal file
25
.gitignore
vendored
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
*.retry
|
||||||
|
.vault-pass
|
||||||
|
facts_cache/
|
||||||
|
*.vault
|
||||||
|
*.secret
|
||||||
|
*.pem
|
||||||
|
*.key
|
||||||
|
*.p12
|
||||||
|
*.pfx
|
||||||
|
.env
|
||||||
|
.env.*
|
||||||
|
id_rsa
|
||||||
|
id_ed25519
|
||||||
|
__pycache__/
|
||||||
|
*.pyc
|
||||||
|
*.swp
|
||||||
|
*.swo
|
||||||
|
*~
|
||||||
|
.vscode/
|
||||||
|
.idea/
|
||||||
|
tmp/
|
||||||
|
dist/
|
||||||
|
*.tar
|
||||||
|
*.tar.gz
|
||||||
|
*.zip
|
||||||
10
CHANGELOG.md
10
CHANGELOG.md
|
|
@ -3,7 +3,9 @@
|
||||||
## 2026-06-19
|
## 2026-06-19
|
||||||
|
|
||||||
### Ajouté
|
### Ajouté
|
||||||
- Ajout d’une structure globale pour `Set-OPS`.
|
- Structure initiale globale du dépôt Set-OPS.
|
||||||
- Ajout d’un espace dédié aux templates VM sans rendre le dépôt exclusif à Proxmox.
|
- Playbooks de création du template Debian 13 Proxmox.
|
||||||
- Ajout des playbooks `vm_templates/debian13_proxmox_*`.
|
- Rôles de base Debian.
|
||||||
- Ajout de rôles classés par domaine : `base`, `security`, `vm_template`.
|
- Rôles de hardening template-safe.
|
||||||
|
- Playbook de vérification.
|
||||||
|
- Playbook de nettoyage final avant conversion en template.
|
||||||
|
|
|
||||||
216
CLAUDE.md
216
CLAUDE.md
|
|
@ -1,221 +1,19 @@
|
||||||
# CLAUDE.md — Set-OPS
|
# CLAUDE.md — Set-OPS
|
||||||
|
|
||||||
## Instruction principale
|
Claude Code doit lire et respecter `AGENTS.md`.
|
||||||
|
|
||||||
Claude Code doit lire et respecter `AGENTS.md` avant toute modification dans ce dépôt.
|
`AGENTS.md` est la source d'autorité principale.
|
||||||
|
|
||||||
`AGENTS.md` est la source d’autorité principale pour :
|
Avant modification :
|
||||||
|
|
||||||
- les principes Ansible ;
|
|
||||||
- la structure du dépôt ;
|
|
||||||
- les règles de sécurité ;
|
|
||||||
- les conventions de nommage ;
|
|
||||||
- la gestion du `CHANGELOG.md` ;
|
|
||||||
- les limites sur les actions destructives ;
|
|
||||||
- la règle : Codex ou Claude Code, jamais les deux en même temps.
|
|
||||||
|
|
||||||
En cas de contradiction entre `CLAUDE.md` et `AGENTS.md`, suivre `AGENTS.md`.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Règle d’or IA
|
|
||||||
|
|
||||||
Un seul agent IA travaille dans ce dépôt à la fois.
|
|
||||||
|
|
||||||
- Soit Codex.
|
|
||||||
- Soit Claude Code.
|
|
||||||
- Jamais les deux simultanément.
|
|
||||||
|
|
||||||
Avant de modifier quoi que ce soit, vérifier l’état du dépôt :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
git status --short
|
|
||||||
```
|
|
||||||
|
|
||||||
Ne pas continuer si des changements non compris sont présents.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Comportement attendu de Claude Code
|
|
||||||
|
|
||||||
Avant de modifier :
|
|
||||||
|
|
||||||
1. Lire `AGENTS.md`.
|
1. Lire `AGENTS.md`.
|
||||||
2. Lire `README.md`, `CHANGELOG.md` et `ansible.cfg` s’ils existent.
|
2. Lire `README.md`, `CHANGELOG.md` et `ansible.cfg`.
|
||||||
3. Inspecter l’arborescence existante.
|
3. Vérifier `git status --short`.
|
||||||
4. Identifier la portée exacte de la demande.
|
4. Proposer le plus petit changement utile.
|
||||||
5. Proposer le plus petit changement utile.
|
|
||||||
6. Préserver les conventions existantes.
|
|
||||||
7. Ne pas réorganiser massivement le dépôt sans demande explicite.
|
|
||||||
|
|
||||||
Après modification :
|
Après modification :
|
||||||
|
|
||||||
1. Résumer les fichiers modifiés.
|
1. Résumer les fichiers modifiés.
|
||||||
2. Indiquer les commandes de validation.
|
2. Indiquer les commandes de validation.
|
||||||
3. Signaler clairement ce qui n’a pas été testé.
|
3. Signaler ce qui n'a pas été testé.
|
||||||
4. Mettre à jour `CHANGELOG.md` si pertinent.
|
4. Mettre à jour `CHANGELOG.md` si pertinent.
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Limites de sécurité
|
|
||||||
|
|
||||||
Ne jamais commiter ou générer :
|
|
||||||
|
|
||||||
- mots de passe ;
|
|
||||||
- clés privées SSH ;
|
|
||||||
- tokens API ;
|
|
||||||
- secrets non chiffrés ;
|
|
||||||
- fichiers `.env` sensibles ;
|
|
||||||
- certificats privés ;
|
|
||||||
- backups réels ;
|
|
||||||
- exports de production non anonymisés ;
|
|
||||||
- fichiers contenant des informations confidentielles de Chezlepro Inc.
|
|
||||||
|
|
||||||
Toute variable sensible doit être gérée hors dépôt ou avec un mécanisme explicitement prévu, par exemple :
|
|
||||||
|
|
||||||
- Ansible Vault ;
|
|
||||||
- fichier local non versionné ;
|
|
||||||
- secret injecté hors dépôt.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Actions destructives
|
|
||||||
|
|
||||||
Toute action pouvant causer une perte d’accès, de données ou de disponibilité doit être protégée.
|
|
||||||
|
|
||||||
Exemples :
|
|
||||||
|
|
||||||
- suppression de paquets critiques ;
|
|
||||||
- modification SSH bloquante ;
|
|
||||||
- modification firewall ;
|
|
||||||
- redémarrage massif ;
|
|
||||||
- formatage disque ;
|
|
||||||
- modification de partitions ;
|
|
||||||
- suppression d’utilisateurs ;
|
|
||||||
- purge de données ;
|
|
||||||
- changement réseau pouvant couper l’accès.
|
|
||||||
|
|
||||||
Pour ces actions, exiger une confirmation explicite ou une variable du type :
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
confirm_destructive_action: true
|
|
||||||
```
|
|
||||||
|
|
||||||
Sans cette confirmation, refuser l’exécution.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## SSH
|
|
||||||
|
|
||||||
État transitoire accepté pendant la construction :
|
|
||||||
|
|
||||||
```text
|
|
||||||
PasswordAuthentication yes
|
|
||||||
```
|
|
||||||
|
|
||||||
État cible recommandé :
|
|
||||||
|
|
||||||
```text
|
|
||||||
PermitRootLogin no
|
|
||||||
PubkeyAuthentication yes
|
|
||||||
PasswordAuthentication no
|
|
||||||
```
|
|
||||||
|
|
||||||
Ne jamais désactiver l’authentification par mot de passe avant d’avoir confirmé que l’accès SSH par clé fonctionne.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Sudo
|
|
||||||
|
|
||||||
Le compte technique `ansible` peut être configuré avec sudo sans mot de passe lorsque c’est requis pour l’automatisation :
|
|
||||||
|
|
||||||
```text
|
|
||||||
ansible ALL=(ALL) NOPASSWD:ALL
|
|
||||||
```
|
|
||||||
|
|
||||||
Cette règle doit être placée dans :
|
|
||||||
|
|
||||||
```text
|
|
||||||
/etc/sudoers.d/90-ansible
|
|
||||||
```
|
|
||||||
|
|
||||||
Toujours valider avec :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
visudo -cf /etc/sudoers.d/90-ansible
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Ansible
|
|
||||||
|
|
||||||
Les playbooks doivent rester :
|
|
||||||
|
|
||||||
- idempotents ;
|
|
||||||
- lisibles ;
|
|
||||||
- sobres ;
|
|
||||||
- compatibles Debian 13 sauf exception documentée ;
|
|
||||||
- testables avec `--check` autant que possible ;
|
|
||||||
- exempts de dépendances SaaS ou cloud inutiles.
|
|
||||||
|
|
||||||
Préférer les modules `ansible.builtin.*`.
|
|
||||||
|
|
||||||
Éviter `shell` et `command` sauf nécessité réelle. Si une commande shell est utilisée, elle doit être encadrée avec les paramètres appropriés :
|
|
||||||
|
|
||||||
- `changed_when`
|
|
||||||
- `failed_when`
|
|
||||||
- `creates`
|
|
||||||
- `removes`
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Validation minimale
|
|
||||||
|
|
||||||
Avant de considérer une modification comme terminée, tenter les validations pertinentes :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
ansible-playbook --syntax-check playbooks/nom.yml
|
|
||||||
ansible-playbook -i inventories/lab/hosts.yml playbooks/nom.yml --check
|
|
||||||
ansible-lint
|
|
||||||
```
|
|
||||||
|
|
||||||
Si une commande de validation n’a pas été exécutée ou si un outil est absent, le signaler clairement.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## CHANGELOG
|
|
||||||
|
|
||||||
Chaque modification significative doit être inscrite dans `CHANGELOG.md`.
|
|
||||||
|
|
||||||
Format recommandé :
|
|
||||||
|
|
||||||
```markdown
|
|
||||||
## YYYY-MM-DD
|
|
||||||
|
|
||||||
### Ajouté
|
|
||||||
- ...
|
|
||||||
|
|
||||||
### Modifié
|
|
||||||
- ...
|
|
||||||
|
|
||||||
### Corrigé
|
|
||||||
- ...
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## Résumé opérationnel
|
|
||||||
|
|
||||||
Set-OPS est un dépôt d’exploitation réelle pour les serveurs de Chezlepro Inc.
|
|
||||||
|
|
||||||
Priorités :
|
|
||||||
|
|
||||||
- reproductibilité ;
|
|
||||||
- sobriété ;
|
|
||||||
- clarté ;
|
|
||||||
- sécurité ;
|
|
||||||
- maintenance ;
|
|
||||||
- autonomie ;
|
|
||||||
- résilience.
|
|
||||||
|
|
||||||
La complexité doit toujours être justifiée par un bénéfice opérationnel clair.
|
|
||||||
|
|
|
||||||
96
README.md
96
README.md
|
|
@ -1,70 +1,23 @@
|
||||||
# Set-OPS — exploitation Ansible Chezlepro
|
# Set-OPS
|
||||||
|
|
||||||
`Set-OPS` est le dépôt Ansible central pour construire, configurer, maintenir et documenter les systèmes de Chezlepro Inc.
|
Dépôt Ansible central pour construire, configurer, maintenir et documenter les systèmes de Chezlepro Inc.
|
||||||
|
|
||||||
Ce dépôt n’est pas exclusif à la création du template Proxmox.
|
## Domaines prévus
|
||||||
Le template Debian 13 n’est qu’un premier chantier dans une structure plus large.
|
|
||||||
|
|
||||||
## Portée du dépôt
|
- templates de VM Proxmox ;
|
||||||
|
- socle Debian ;
|
||||||
|
- hardening ;
|
||||||
|
- maintenance ;
|
||||||
|
- web ;
|
||||||
|
- bases de données ;
|
||||||
|
- monitoring ;
|
||||||
|
- sauvegardes ;
|
||||||
|
- identité ;
|
||||||
|
- applications.
|
||||||
|
|
||||||
Le dépôt doit pouvoir accueillir progressivement :
|
## Premier chantier
|
||||||
|
|
||||||
- les templates de VM Proxmox ;
|
Template Debian 13 Proxmox :
|
||||||
- les socles Debian ;
|
|
||||||
- le durcissement SSH ;
|
|
||||||
- les utilisateurs et sudo ;
|
|
||||||
- le reverse proxy ;
|
|
||||||
- les serveurs web statiques ;
|
|
||||||
- les bases de données ;
|
|
||||||
- la supervision ;
|
|
||||||
- les sauvegardes ;
|
|
||||||
- les services applicatifs ;
|
|
||||||
- les tâches de maintenance ;
|
|
||||||
- les validations et audits ;
|
|
||||||
- la documentation d’exploitation.
|
|
||||||
|
|
||||||
## Principe d’organisation
|
|
||||||
|
|
||||||
Les playbooks sont classés par domaine fonctionnel :
|
|
||||||
|
|
||||||
```text
|
|
||||||
playbooks/
|
|
||||||
├── bootstrap/
|
|
||||||
├── baseline/
|
|
||||||
├── hardening/
|
|
||||||
├── maintenance/
|
|
||||||
├── monitoring/
|
|
||||||
├── networking/
|
|
||||||
├── storage/
|
|
||||||
├── proxmox/
|
|
||||||
├── vm_templates/
|
|
||||||
├── web/
|
|
||||||
├── database/
|
|
||||||
├── identity/
|
|
||||||
├── backup/
|
|
||||||
└── applications/
|
|
||||||
```
|
|
||||||
|
|
||||||
Les rôles sont également classés par domaine :
|
|
||||||
|
|
||||||
```text
|
|
||||||
roles/
|
|
||||||
├── base/
|
|
||||||
├── security/
|
|
||||||
├── proxmox/
|
|
||||||
├── vm_template/
|
|
||||||
├── web/
|
|
||||||
├── database/
|
|
||||||
├── monitoring/
|
|
||||||
├── backup/
|
|
||||||
├── identity/
|
|
||||||
├── storage/
|
|
||||||
└── applications/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Template Debian 13 Proxmox
|
|
||||||
|
|
||||||
La préparation du modèle Debian 13 se trouve dans :
|
|
||||||
|
|
||||||
```text
|
```text
|
||||||
playbooks/vm_templates/debian13_proxmox_prepare.yml
|
playbooks/vm_templates/debian13_proxmox_prepare.yml
|
||||||
|
|
@ -72,16 +25,15 @@ playbooks/vm_templates/debian13_proxmox_verify.yml
|
||||||
playbooks/vm_templates/debian13_proxmox_cleanup.yml
|
playbooks/vm_templates/debian13_proxmox_cleanup.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Les rôles associés se trouvent principalement dans :
|
## Principe
|
||||||
|
|
||||||
```text
|
Le template contient seulement le socle commun.
|
||||||
roles/base/
|
|
||||||
roles/security/
|
|
||||||
roles/vm_template/
|
|
||||||
```
|
|
||||||
|
|
||||||
## Règle importante
|
Les services spécialisés seront installés ensuite sur les clones :
|
||||||
|
|
||||||
Le template de VM doit contenir seulement le socle commun.
|
- NGINX ;
|
||||||
|
- PostgreSQL ;
|
||||||
Les logiciels applicatifs lourds — NGINX, PostgreSQL, MariaDB, Docker/Podman, Redis, Nextcloud, GitLab, monitoring complet — doivent être installés par des playbooks dédiés sur les clones, pas directement dans le template.
|
- MariaDB ;
|
||||||
|
- Docker/Podman ;
|
||||||
|
- monitoring complet ;
|
||||||
|
- applications métier.
|
||||||
|
|
|
||||||
62
SOLUTION.md
Normal file
62
SOLUTION.md
Normal file
|
|
@ -0,0 +1,62 @@
|
||||||
|
# La solution Set-OPS
|
||||||
|
|
||||||
|
## Décision
|
||||||
|
|
||||||
|
`Set-OPS` est le dépôt Ansible global de Chezlepro Inc.
|
||||||
|
|
||||||
|
Le template Debian 13 Proxmox est seulement un chantier dans ce dépôt.
|
||||||
|
|
||||||
|
## Ce qu'on fait maintenant
|
||||||
|
|
||||||
|
On garde une seule structure simple :
|
||||||
|
|
||||||
|
```text
|
||||||
|
inventories/
|
||||||
|
playbooks/
|
||||||
|
roles/
|
||||||
|
docs/
|
||||||
|
```
|
||||||
|
|
||||||
|
Les rôles sont nommés clairement, sans sous-arborescence complexe.
|
||||||
|
|
||||||
|
## Commande principale pour construire le template
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_prepare.yml --ask-pass --ask-become-pass
|
||||||
|
```
|
||||||
|
|
||||||
|
Après que sudo sans mot de passe fonctionne :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_prepare.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Vérification
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_verify.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Nettoyage final avant conversion
|
||||||
|
|
||||||
|
```bash
|
||||||
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_cleanup.yml -e confirm_template_cleanup=true
|
||||||
|
```
|
||||||
|
|
||||||
|
Ensuite :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
sudo shutdown -h now
|
||||||
|
```
|
||||||
|
|
||||||
|
Puis côté Proxmox :
|
||||||
|
|
||||||
|
```bash
|
||||||
|
qm template VMID
|
||||||
|
```
|
||||||
|
|
||||||
|
## Important
|
||||||
|
|
||||||
|
Le pare-feu `nftables` est installé et préparé, mais il n'est pas activé par défaut dans le template.
|
||||||
|
|
||||||
|
C'est volontaire pour éviter de couper SSH pendant la construction.
|
||||||
|
|
@ -1,26 +1,18 @@
|
||||||
# Architecture Set-OPS
|
# Architecture Set-OPS
|
||||||
|
|
||||||
`Set-OPS` est un dépôt global d’exploitation.
|
Set-OPS est un dépôt global d'exploitation.
|
||||||
|
|
||||||
## Domaines
|
## Domaines
|
||||||
|
|
||||||
```text
|
```text
|
||||||
bootstrap : premier accès, comptes, prérequis
|
|
||||||
baseline : socle commun Debian
|
baseline : socle commun Debian
|
||||||
hardening : sécurité et durcissement
|
hardening : sécurité
|
||||||
maintenance : mises à jour, nettoyage, redémarrages contrôlés
|
maintenance : mises à jour
|
||||||
monitoring : supervision
|
monitoring : supervision
|
||||||
networking : DNS, pare-feu, réseau
|
proxmox : hyperviseurs
|
||||||
storage : stockage, montages, clients
|
|
||||||
proxmox : opérations hyperviseur
|
|
||||||
vm_templates : modèles de VM
|
vm_templates : modèles de VM
|
||||||
web : NGINX, sites, reverse proxy
|
web : services web
|
||||||
database : PostgreSQL, MariaDB
|
database : bases de données
|
||||||
identity : IAM, Keycloak, annuaires
|
|
||||||
backup : sauvegardes
|
backup : sauvegardes
|
||||||
applications : services applicatifs
|
applications : services applicatifs
|
||||||
```
|
```
|
||||||
|
|
||||||
## Règle
|
|
||||||
|
|
||||||
Le template Debian 13 Proxmox est un composant de `Set-OPS`, pas le dépôt au complet.
|
|
||||||
|
|
|
||||||
|
|
@ -1,29 +1,19 @@
|
||||||
# Template Debian 13 Proxmox
|
# Template Debian 13 Proxmox
|
||||||
|
|
||||||
## Playbooks
|
## Préparation
|
||||||
|
|
||||||
Préparation :
|
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_prepare.yml --ask-pass --ask-become-pass
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_prepare.yml --ask-pass --ask-become-pass
|
||||||
```
|
```
|
||||||
|
|
||||||
Vérification :
|
## Vérification
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_verify.yml
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_verify.yml
|
||||||
```
|
```
|
||||||
|
|
||||||
Nettoyage final :
|
## Nettoyage
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_cleanup.yml -e confirm_template_cleanup=true
|
ansible-playbook -i inventories/lab/hosts.yml playbooks/vm_templates/debian13_proxmox_cleanup.yml -e confirm_template_cleanup=true
|
||||||
```
|
```
|
||||||
|
|
||||||
## Conversion Proxmox
|
|
||||||
|
|
||||||
Après extinction :
|
|
||||||
|
|
||||||
```bash
|
|
||||||
qm template VMID
|
|
||||||
```
|
|
||||||
|
|
|
||||||
|
|
@ -2,17 +2,59 @@
|
||||||
chezlepro_timezone: "America/Toronto"
|
chezlepro_timezone: "America/Toronto"
|
||||||
chezlepro_admin_user: "ansible"
|
chezlepro_admin_user: "ansible"
|
||||||
|
|
||||||
|
# SSH pendant la construction du template.
|
||||||
|
# Passer à "no" seulement après validation des clés SSH.
|
||||||
|
chezlepro_ssh_port: 22
|
||||||
chezlepro_ssh_password_authentication: "yes"
|
chezlepro_ssh_password_authentication: "yes"
|
||||||
chezlepro_ssh_permit_root_login: "no"
|
chezlepro_ssh_permit_root_login: "no"
|
||||||
chezlepro_ssh_pubkey_authentication: "yes"
|
chezlepro_ssh_pubkey_authentication: "yes"
|
||||||
|
chezlepro_ssh_client_alive_interval: 300
|
||||||
|
chezlepro_ssh_client_alive_count_max: 2
|
||||||
|
chezlepro_ssh_max_auth_tries: 4
|
||||||
|
chezlepro_ssh_login_grace_time: "30s"
|
||||||
|
|
||||||
|
# systemd-ssh-generator / VSOCK
|
||||||
chezlepro_disable_systemd_ssh_auto: true
|
chezlepro_disable_systemd_ssh_auto: true
|
||||||
|
|
||||||
|
# Cloud-init
|
||||||
cloud_init_ssh_pwauth: true
|
cloud_init_ssh_pwauth: true
|
||||||
cloud_init_manage_etc_hosts: true
|
cloud_init_manage_etc_hosts: true
|
||||||
cloud_init_disable_root: true
|
cloud_init_disable_root: true
|
||||||
cloud_init_ssh_deletekeys: true
|
cloud_init_ssh_deletekeys: true
|
||||||
|
|
||||||
|
# Pare-feu : préparé mais non activé dans le template.
|
||||||
|
chezlepro_nftables_enabled: false
|
||||||
|
chezlepro_firewall_allow_ssh: true
|
||||||
|
chezlepro_firewall_allow_icmp: true
|
||||||
|
chezlepro_firewall_input_policy: "drop"
|
||||||
|
chezlepro_firewall_forward_policy: "drop"
|
||||||
|
chezlepro_firewall_output_policy: "accept"
|
||||||
|
chezlepro_firewall_extra_tcp_ports: []
|
||||||
|
chezlepro_firewall_extra_udp_ports: []
|
||||||
|
|
||||||
|
# Fail2ban
|
||||||
|
chezlepro_fail2ban_enabled: true
|
||||||
|
chezlepro_fail2ban_bantime: "1h"
|
||||||
|
chezlepro_fail2ban_findtime: "10m"
|
||||||
|
chezlepro_fail2ban_maxretry: 5
|
||||||
|
|
||||||
|
# Sécurité
|
||||||
|
chezlepro_auditd_enabled: true
|
||||||
|
chezlepro_apparmor_enabled: true
|
||||||
|
chezlepro_sysctl_apply: true
|
||||||
|
chezlepro_disable_core_dumps: true
|
||||||
|
|
||||||
|
# Unattended upgrades
|
||||||
|
chezlepro_unattended_upgrades_enabled: true
|
||||||
|
chezlepro_unattended_remove_unused_dependencies: true
|
||||||
|
chezlepro_unattended_automatic_reboot: false
|
||||||
|
|
||||||
|
# Journald
|
||||||
|
chezlepro_journald_system_max_use: "200M"
|
||||||
|
chezlepro_journald_runtime_max_use: "100M"
|
||||||
|
chezlepro_journald_max_retention_sec: "1month"
|
||||||
|
|
||||||
|
# Nettoyage final
|
||||||
confirm_template_cleanup: false
|
confirm_template_cleanup: false
|
||||||
|
|
||||||
chezlepro_common_packages:
|
chezlepro_common_packages:
|
||||||
|
|
@ -62,3 +104,16 @@ chezlepro_common_packages:
|
||||||
- unattended-upgrades
|
- unattended-upgrades
|
||||||
- apt-listchanges
|
- apt-listchanges
|
||||||
- needrestart
|
- needrestart
|
||||||
|
|
||||||
|
chezlepro_hardening_packages:
|
||||||
|
- apparmor
|
||||||
|
- apparmor-utils
|
||||||
|
- auditd
|
||||||
|
- audispd-plugins
|
||||||
|
- fail2ban
|
||||||
|
- nftables
|
||||||
|
- unattended-upgrades
|
||||||
|
- apt-listchanges
|
||||||
|
- debsums
|
||||||
|
- needrestart
|
||||||
|
- libpam-pwquality
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ all:
|
||||||
vm_templates:
|
vm_templates:
|
||||||
hosts:
|
hosts:
|
||||||
basiqueChezlepro:
|
basiqueChezlepro:
|
||||||
ansible_host: 192.168.11.150
|
ansible_host: 192.168.12.99
|
||||||
ansible_user: ansible
|
ansible_user: ansible
|
||||||
ansible_become: true
|
ansible_become: true
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,11 @@ all:
|
||||||
children:
|
children:
|
||||||
vm_templates:
|
vm_templates:
|
||||||
hosts: {}
|
hosts: {}
|
||||||
|
|
||||||
web_servers:
|
web_servers:
|
||||||
hosts: {}
|
hosts: {}
|
||||||
|
|
||||||
database_servers:
|
database_servers:
|
||||||
hosts: {}
|
hosts: {}
|
||||||
|
|
||||||
monitoring_servers:
|
monitoring_servers:
|
||||||
hosts: {}
|
hosts: {}
|
||||||
|
|
||||||
proxmox_hosts:
|
proxmox_hosts:
|
||||||
hosts: {}
|
hosts: {}
|
||||||
|
|
|
||||||
3
playbooks/applications/README.md
Normal file
3
playbooks/applications/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Playbooks applications
|
||||||
|
|
||||||
|
Espace réservé aux futurs playbooks.
|
||||||
3
playbooks/backup/README.md
Normal file
3
playbooks/backup/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Playbooks backup
|
||||||
|
|
||||||
|
Espace réservé aux futurs playbooks.
|
||||||
|
|
@ -5,6 +5,6 @@
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: base/common_packages
|
- common_packages
|
||||||
- role: base/chrony
|
- chrony
|
||||||
- role: security/ssh_baseline
|
- ssh_baseline
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
# Playbooks database
|
# Playbooks database
|
||||||
|
|
||||||
Espace réservé aux futurs playbooks de bases de données :
|
Espace réservé aux futurs playbooks.
|
||||||
|
|
||||||
- PostgreSQL ;
|
|
||||||
- MariaDB ;
|
|
||||||
- sauvegardes ;
|
|
||||||
- réplication ;
|
|
||||||
- durcissement.
|
|
||||||
|
|
|
||||||
24
playbooks/hardening/debian_server_hardening.yml
Normal file
24
playbooks/hardening/debian_server_hardening.yml
Normal file
|
|
@ -0,0 +1,24 @@
|
||||||
|
---
|
||||||
|
- name: Appliquer le hardening Debian serveur Chezlepro
|
||||||
|
hosts: all
|
||||||
|
become: true
|
||||||
|
gather_facts: true
|
||||||
|
|
||||||
|
pre_tasks:
|
||||||
|
- name: Vérifier que la cible est Debian
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- ansible_facts.distribution == "Debian"
|
||||||
|
fail_msg: "Ce playbook est prévu pour Debian."
|
||||||
|
|
||||||
|
roles:
|
||||||
|
- hardening_packages
|
||||||
|
- sysctl_hardening
|
||||||
|
- core_dumps
|
||||||
|
- unattended_upgrades
|
||||||
|
- apparmor
|
||||||
|
- auditd
|
||||||
|
- fail2ban_ssh
|
||||||
|
- journald
|
||||||
|
- ssh_hardening
|
||||||
|
- nftables_baseline
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
# Playbooks monitoring
|
# Playbooks monitoring
|
||||||
|
|
||||||
Espace réservé aux futurs playbooks de supervision :
|
Espace réservé aux futurs playbooks.
|
||||||
|
|
||||||
- agents ;
|
|
||||||
- sondes ;
|
|
||||||
- Icinga/Nagios ;
|
|
||||||
- exporters ;
|
|
||||||
- règles d’alerte.
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,3 @@
|
||||||
# Playbooks Proxmox
|
# Playbooks Proxmox
|
||||||
|
|
||||||
Espace réservé aux opérations Proxmox.
|
Espace réservé aux futurs playbooks.
|
||||||
|
|
||||||
Attention : les actions sur les hyperviseurs et le stockage doivent être protégées par confirmation explicite.
|
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,12 @@
|
||||||
---
|
---
|
||||||
- name: Point d’entrée général Set-OPS
|
- name: Point d'entrée général Set-OPS
|
||||||
hosts: all
|
hosts: all
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
become: true
|
become: true
|
||||||
|
|
||||||
tasks:
|
tasks:
|
||||||
- name: Afficher un message volontairement non destructif
|
- name: Message
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg:
|
msg:
|
||||||
- "Set-OPS est un dépôt global."
|
- "Set-OPS est un dépôt global."
|
||||||
- "Utiliser un playbook spécialisé : baseline, vm_templates, web, database, monitoring, etc."
|
- "Utiliser un playbook spécialisé."
|
||||||
|
|
|
||||||
|
|
@ -5,4 +5,4 @@
|
||||||
gather_facts: true
|
gather_facts: true
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: vm_template/template_cleanup
|
- template_cleanup
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@
|
||||||
ansible.builtin.assert:
|
ansible.builtin.assert:
|
||||||
that:
|
that:
|
||||||
- ansible_facts.distribution == "Debian"
|
- ansible_facts.distribution == "Debian"
|
||||||
fail_msg: "Ce playbook est prévu pour Debian seulement."
|
fail_msg: "Ce playbook est prévu pour Debian."
|
||||||
|
|
||||||
- name: Avertir si la version Debian n'est pas 13
|
- name: Avertir si la version Debian n'est pas 13
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
|
|
@ -17,14 +17,24 @@
|
||||||
when: ansible_facts.distribution_major_version != "13"
|
when: ansible_facts.distribution_major_version != "13"
|
||||||
|
|
||||||
roles:
|
roles:
|
||||||
- role: base/common_packages
|
- common_packages
|
||||||
- role: base/qemu_guest_agent
|
- qemu_guest_agent
|
||||||
- role: base/cloud_init
|
- cloud_init
|
||||||
- role: security/sudo_ansible
|
- sudo_ansible
|
||||||
- role: base/chrony
|
- chrony
|
||||||
- role: security/ssh_baseline
|
- ssh_baseline
|
||||||
- role: vm_template/systemd_ssh_auto
|
- systemd_ssh_auto
|
||||||
- role: base/motd
|
- motd
|
||||||
|
- hardening_packages
|
||||||
|
- sysctl_hardening
|
||||||
|
- core_dumps
|
||||||
|
- unattended_upgrades
|
||||||
|
- apparmor
|
||||||
|
- auditd
|
||||||
|
- fail2ban_ssh
|
||||||
|
- journald
|
||||||
|
- ssh_hardening
|
||||||
|
- nftables_baseline
|
||||||
|
|
||||||
post_tasks:
|
post_tasks:
|
||||||
- name: Afficher le statut cloud-init
|
- name: Afficher le statut cloud-init
|
||||||
|
|
@ -37,9 +47,10 @@
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: cloud_init_status.stdout_lines
|
var: cloud_init_status.stdout_lines
|
||||||
|
|
||||||
- name: Rappel
|
- name: Message final
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
msg:
|
msg:
|
||||||
- "Préparation terminée."
|
- "Préparation terminée."
|
||||||
- "Si GRUB a été modifié, redémarrer la VM avant validation finale."
|
- "Redémarrer si GRUB a changé."
|
||||||
- "Ne pas convertir en template avant le playbook de nettoyage."
|
- "Ne pas convertir avant le playbook de nettoyage final."
|
||||||
|
- "nftables est installé mais désactivé par défaut."
|
||||||
|
|
|
||||||
|
|
@ -39,3 +39,13 @@
|
||||||
- name: Afficher cloud-init
|
- name: Afficher cloud-init
|
||||||
ansible.builtin.debug:
|
ansible.builtin.debug:
|
||||||
var: cloud_init_version.stdout
|
var: cloud_init_version.stdout
|
||||||
|
|
||||||
|
- name: Vérifier les erreurs critiques du boot courant
|
||||||
|
ansible.builtin.command: journalctl -b -p err..alert --no-pager
|
||||||
|
register: boot_errors
|
||||||
|
changed_when: false
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Afficher les erreurs du boot courant
|
||||||
|
ansible.builtin.debug:
|
||||||
|
var: boot_errors.stdout_lines
|
||||||
|
|
|
||||||
|
|
@ -1,9 +1,3 @@
|
||||||
# Playbooks web
|
# Playbooks web
|
||||||
|
|
||||||
Espace réservé aux futurs playbooks web :
|
Espace réservé aux futurs playbooks.
|
||||||
|
|
||||||
- reverse proxy ;
|
|
||||||
- NGINX ;
|
|
||||||
- sites statiques ;
|
|
||||||
- certificats ;
|
|
||||||
- publication locale.
|
|
||||||
|
|
|
||||||
3
roles/apparmor/README.md
Normal file
3
roles/apparmor/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle apparmor
|
||||||
|
|
||||||
|
Installe et active AppArmor.
|
||||||
2
roles/apparmor/defaults/main.yml
Normal file
2
roles/apparmor/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_apparmor_enabled: true
|
||||||
15
roles/apparmor/tasks/main.yml
Normal file
15
roles/apparmor/tasks/main.yml
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
---
|
||||||
|
- name: Installer AppArmor
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- apparmor
|
||||||
|
- apparmor-utils
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Activer AppArmor
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: apparmor
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
when: chezlepro_apparmor_enabled | bool
|
||||||
|
failed_when: false
|
||||||
3
roles/auditd/README.md
Normal file
3
roles/auditd/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle auditd
|
||||||
|
|
||||||
|
Installe auditd et ajoute des règles sobres.
|
||||||
2
roles/auditd/defaults/main.yml
Normal file
2
roles/auditd/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_auditd_enabled: true
|
||||||
6
roles/auditd/handlers/main.yml
Normal file
6
roles/auditd/handlers/main.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
- name: Restart auditd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: auditd
|
||||||
|
state: restarted
|
||||||
|
failed_when: false
|
||||||
25
roles/auditd/tasks/main.yml
Normal file
25
roles/auditd/tasks/main.yml
Normal file
|
|
@ -0,0 +1,25 @@
|
||||||
|
---
|
||||||
|
- name: Installer auditd
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- auditd
|
||||||
|
- audispd-plugins
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Déployer les règles auditd Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99-chezlepro.rules.j2
|
||||||
|
dest: /etc/audit/rules.d/99-chezlepro.rules
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0640"
|
||||||
|
notify: Restart auditd
|
||||||
|
when: chezlepro_auditd_enabled | bool
|
||||||
|
|
||||||
|
- name: Activer auditd
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: auditd
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
when: chezlepro_auditd_enabled | bool
|
||||||
|
failed_when: false
|
||||||
19
roles/auditd/templates/99-chezlepro.rules.j2
Normal file
19
roles/auditd/templates/99-chezlepro.rules.j2
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
-D
|
||||||
|
-b 8192
|
||||||
|
-f 1
|
||||||
|
|
||||||
|
-w /etc/passwd -p wa -k identity
|
||||||
|
-w /etc/group -p wa -k identity
|
||||||
|
-w /etc/shadow -p wa -k identity
|
||||||
|
-w /etc/gshadow -p wa -k identity
|
||||||
|
-w /etc/sudoers -p wa -k sudoers
|
||||||
|
-w /etc/sudoers.d/ -p wa -k sudoers
|
||||||
|
-w /etc/ssh/sshd_config -p wa -k sshd
|
||||||
|
-w /etc/ssh/sshd_config.d/ -p wa -k sshd
|
||||||
|
-w /etc/apt/ -p wa -k apt-config
|
||||||
|
|
||||||
|
-a always,exit -F arch=b64 -S adjtimex,settimeofday,clock_settime -k time-change
|
||||||
|
-a always,exit -F arch=b64 -S sethostname,setdomainname -k system-locale
|
||||||
|
|
||||||
|
-e 1
|
||||||
3
roles/chrony/README.md
Normal file
3
roles/chrony/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle chrony
|
||||||
|
|
||||||
|
Installe et active chrony.
|
||||||
11
roles/chrony/tasks/main.yml
Normal file
11
roles/chrony/tasks/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Installer chrony
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: chrony
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Activer et démarrer chrony
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: chrony
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
3
roles/cloud_init/README.md
Normal file
3
roles/cloud_init/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle cloud_init
|
||||||
|
|
||||||
|
Installe et configure cloud-init pour Proxmox.
|
||||||
5
roles/cloud_init/defaults/main.yml
Normal file
5
roles/cloud_init/defaults/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
cloud_init_ssh_pwauth: true
|
||||||
|
cloud_init_manage_etc_hosts: true
|
||||||
|
cloud_init_disable_root: true
|
||||||
|
cloud_init_ssh_deletekeys: true
|
||||||
32
roles/cloud_init/tasks/main.yml
Normal file
32
roles/cloud_init/tasks/main.yml
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
---
|
||||||
|
- name: Installer cloud-init et cloud-guest-utils
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- cloud-init
|
||||||
|
- cloud-guest-utils
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Déployer la configuration cloud-init Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99_chezlepro.cfg.j2
|
||||||
|
dest: /etc/cloud/cloud.cfg.d/99_chezlepro.cfg
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Activer les services cloud-init Debian 13
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: "{{ item }}"
|
||||||
|
enabled: true
|
||||||
|
loop:
|
||||||
|
- cloud-init-local.service
|
||||||
|
- cloud-init-main.service
|
||||||
|
- cloud-init-network.service
|
||||||
|
- cloud-config.service
|
||||||
|
- cloud-final.service
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Vérifier cloud-init
|
||||||
|
ansible.builtin.command: cloud-init --version
|
||||||
|
register: cloud_init_version
|
||||||
|
changed_when: false
|
||||||
22
roles/cloud_init/templates/99_chezlepro.cfg.j2
Normal file
22
roles/cloud_init/templates/99_chezlepro.cfg.j2
Normal file
|
|
@ -0,0 +1,22 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
datasource_list: [ NoCloud, ConfigDrive, None ]
|
||||||
|
|
||||||
|
preserve_hostname: false
|
||||||
|
manage_etc_hosts: {{ cloud_init_manage_etc_hosts | bool | lower }}
|
||||||
|
disable_root: {{ cloud_init_disable_root | bool | lower }}
|
||||||
|
ssh_pwauth: {{ cloud_init_ssh_pwauth | bool | lower }}
|
||||||
|
|
||||||
|
ssh_deletekeys: {{ cloud_init_ssh_deletekeys | bool | lower }}
|
||||||
|
ssh_genkeytypes:
|
||||||
|
- rsa
|
||||||
|
- ecdsa
|
||||||
|
- ed25519
|
||||||
|
|
||||||
|
growpart:
|
||||||
|
mode: auto
|
||||||
|
devices:
|
||||||
|
- /
|
||||||
|
ignore_growroot_disabled: false
|
||||||
|
|
||||||
|
resize_rootfs: true
|
||||||
3
roles/common_packages/README.md
Normal file
3
roles/common_packages/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle common_packages
|
||||||
|
|
||||||
|
Installe le socle logiciel commun.
|
||||||
2
roles/common_packages/defaults/main.yml
Normal file
2
roles/common_packages/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_common_packages: []
|
||||||
18
roles/common_packages/tasks/main.yml
Normal file
18
roles/common_packages/tasks/main.yml
Normal file
|
|
@ -0,0 +1,18 @@
|
||||||
|
---
|
||||||
|
- name: Mettre à jour le cache APT
|
||||||
|
ansible.builtin.apt:
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
|
|
||||||
|
- name: Appliquer les mises à jour disponibles
|
||||||
|
ansible.builtin.apt:
|
||||||
|
upgrade: full
|
||||||
|
|
||||||
|
- name: Installer les paquets communs
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ chezlepro_common_packages }}"
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Supprimer les dépendances devenues inutiles
|
||||||
|
ansible.builtin.apt:
|
||||||
|
autoremove: true
|
||||||
3
roles/core_dumps/README.md
Normal file
3
roles/core_dumps/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle core_dumps
|
||||||
|
|
||||||
|
Désactive les core dumps.
|
||||||
2
roles/core_dumps/defaults/main.yml
Normal file
2
roles/core_dumps/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_disable_core_dumps: true
|
||||||
19
roles/core_dumps/tasks/main.yml
Normal file
19
roles/core_dumps/tasks/main.yml
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
---
|
||||||
|
- name: Désactiver les core dumps via limits.d
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99-chezlepro-core-dumps.conf.j2
|
||||||
|
dest: /etc/security/limits.d/99-chezlepro-core-dumps.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when: chezlepro_disable_core_dumps | bool
|
||||||
|
|
||||||
|
- name: Configurer systemd-coredump si présent
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: coredump.conf.j2
|
||||||
|
dest: /etc/systemd/coredump.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when: chezlepro_disable_core_dumps | bool
|
||||||
|
failed_when: false
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
* hard core 0
|
||||||
|
* soft core 0
|
||||||
4
roles/core_dumps/templates/coredump.conf.j2
Normal file
4
roles/core_dumps/templates/coredump.conf.j2
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
[Coredump]
|
||||||
|
Storage=none
|
||||||
|
ProcessSizeMax=0
|
||||||
3
roles/fail2ban_ssh/README.md
Normal file
3
roles/fail2ban_ssh/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle fail2ban_ssh
|
||||||
|
|
||||||
|
Configure fail2ban pour SSH.
|
||||||
6
roles/fail2ban_ssh/defaults/main.yml
Normal file
6
roles/fail2ban_ssh/defaults/main.yml
Normal file
|
|
@ -0,0 +1,6 @@
|
||||||
|
---
|
||||||
|
chezlepro_fail2ban_enabled: true
|
||||||
|
chezlepro_fail2ban_bantime: "1h"
|
||||||
|
chezlepro_fail2ban_findtime: "10m"
|
||||||
|
chezlepro_fail2ban_maxretry: 5
|
||||||
|
chezlepro_ssh_port: 22
|
||||||
5
roles/fail2ban_ssh/handlers/main.yml
Normal file
5
roles/fail2ban_ssh/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Restart fail2ban
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: fail2ban
|
||||||
|
state: restarted
|
||||||
29
roles/fail2ban_ssh/tasks/main.yml
Normal file
29
roles/fail2ban_ssh/tasks/main.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
- name: Installer fail2ban
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: fail2ban
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Créer le répertoire jail.d
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/fail2ban/jail.d
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Déployer la jail SSH Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: sshd-chezlepro.local.j2
|
||||||
|
dest: /etc/fail2ban/jail.d/sshd-chezlepro.local
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Restart fail2ban
|
||||||
|
|
||||||
|
- name: Activer fail2ban
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: fail2ban
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
when: chezlepro_fail2ban_enabled | bool
|
||||||
9
roles/fail2ban_ssh/templates/sshd-chezlepro.local.j2
Normal file
9
roles/fail2ban_ssh/templates/sshd-chezlepro.local.j2
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
[sshd]
|
||||||
|
enabled = {{ 'true' if chezlepro_fail2ban_enabled | bool else 'false' }}
|
||||||
|
port = {{ chezlepro_ssh_port }}
|
||||||
|
backend = systemd
|
||||||
|
maxretry = {{ chezlepro_fail2ban_maxretry }}
|
||||||
|
findtime = {{ chezlepro_fail2ban_findtime }}
|
||||||
|
bantime = {{ chezlepro_fail2ban_bantime }}
|
||||||
3
roles/hardening_packages/README.md
Normal file
3
roles/hardening_packages/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle hardening_packages
|
||||||
|
|
||||||
|
Installe les paquets de hardening Debian.
|
||||||
2
roles/hardening_packages/defaults/main.yml
Normal file
2
roles/hardening_packages/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_hardening_packages: []
|
||||||
7
roles/hardening_packages/tasks/main.yml
Normal file
7
roles/hardening_packages/tasks/main.yml
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
---
|
||||||
|
- name: Installer les paquets de hardening
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: "{{ chezlepro_hardening_packages }}"
|
||||||
|
state: present
|
||||||
|
update_cache: true
|
||||||
|
cache_valid_time: 3600
|
||||||
3
roles/journald/README.md
Normal file
3
roles/journald/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle journald
|
||||||
|
|
||||||
|
Limite et configure journald.
|
||||||
4
roles/journald/defaults/main.yml
Normal file
4
roles/journald/defaults/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
chezlepro_journald_system_max_use: "200M"
|
||||||
|
chezlepro_journald_runtime_max_use: "100M"
|
||||||
|
chezlepro_journald_max_retention_sec: "1month"
|
||||||
5
roles/journald/handlers/main.yml
Normal file
5
roles/journald/handlers/main.yml
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
- name: Restart journald
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: systemd-journald
|
||||||
|
state: restarted
|
||||||
17
roles/journald/tasks/main.yml
Normal file
17
roles/journald/tasks/main.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
- name: Créer le répertoire journald.conf.d
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/journald.conf.d
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Déployer la configuration journald Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99-chezlepro.conf.j2
|
||||||
|
dest: /etc/systemd/journald.conf.d/99-chezlepro.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Restart journald
|
||||||
7
roles/journald/templates/99-chezlepro.conf.j2
Normal file
7
roles/journald/templates/99-chezlepro.conf.j2
Normal file
|
|
@ -0,0 +1,7 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
[Journal]
|
||||||
|
SystemMaxUse={{ chezlepro_journald_system_max_use }}
|
||||||
|
RuntimeMaxUse={{ chezlepro_journald_runtime_max_use }}
|
||||||
|
MaxRetentionSec={{ chezlepro_journald_max_retention_sec }}
|
||||||
|
Compress=yes
|
||||||
|
Seal=yes
|
||||||
3
roles/motd/README.md
Normal file
3
roles/motd/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle motd
|
||||||
|
|
||||||
|
Déploie un MOTD simple.
|
||||||
8
roles/motd/tasks/main.yml
Normal file
8
roles/motd/tasks/main.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
---
|
||||||
|
- name: Déployer le MOTD Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: motd.j2
|
||||||
|
dest: /etc/motd
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
2
roles/motd/templates/motd.j2
Normal file
2
roles/motd/templates/motd.j2
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
Système Chezlepro
|
||||||
|
Gestion : Set-OPS / Ansible
|
||||||
3
roles/nftables_baseline/README.md
Normal file
3
roles/nftables_baseline/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle nftables_baseline
|
||||||
|
|
||||||
|
Prépare nftables. Désactivé par défaut dans le template.
|
||||||
10
roles/nftables_baseline/defaults/main.yml
Normal file
10
roles/nftables_baseline/defaults/main.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
chezlepro_nftables_enabled: false
|
||||||
|
chezlepro_firewall_allow_ssh: true
|
||||||
|
chezlepro_firewall_allow_icmp: true
|
||||||
|
chezlepro_firewall_input_policy: "drop"
|
||||||
|
chezlepro_firewall_forward_policy: "drop"
|
||||||
|
chezlepro_firewall_output_policy: "accept"
|
||||||
|
chezlepro_ssh_port: 22
|
||||||
|
chezlepro_firewall_extra_tcp_ports: []
|
||||||
|
chezlepro_firewall_extra_udp_ports: []
|
||||||
4
roles/nftables_baseline/handlers/main.yml
Normal file
4
roles/nftables_baseline/handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: Reload nftables
|
||||||
|
ansible.builtin.command: nft -f /etc/nftables.conf
|
||||||
|
changed_when: true
|
||||||
30
roles/nftables_baseline/tasks/main.yml
Normal file
30
roles/nftables_baseline/tasks/main.yml
Normal file
|
|
@ -0,0 +1,30 @@
|
||||||
|
---
|
||||||
|
- name: Installer nftables
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: nftables
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Déployer la configuration nftables Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: nftables.conf.j2
|
||||||
|
dest: /etc/nftables.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Reload nftables
|
||||||
|
when: chezlepro_nftables_enabled | bool
|
||||||
|
|
||||||
|
- name: Activer nftables si demandé
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: nftables
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
|
when: chezlepro_nftables_enabled | bool
|
||||||
|
|
||||||
|
- name: Désactiver nftables si demandé
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: nftables
|
||||||
|
enabled: false
|
||||||
|
state: stopped
|
||||||
|
when: not (chezlepro_nftables_enabled | bool)
|
||||||
|
failed_when: false
|
||||||
39
roles/nftables_baseline/templates/nftables.conf.j2
Normal file
39
roles/nftables_baseline/templates/nftables.conf.j2
Normal file
|
|
@ -0,0 +1,39 @@
|
||||||
|
#!/usr/sbin/nft -f
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
flush ruleset
|
||||||
|
|
||||||
|
table inet chezlepro_filter {
|
||||||
|
chain input {
|
||||||
|
type filter hook input priority 0; policy {{ chezlepro_firewall_input_policy }};
|
||||||
|
|
||||||
|
iif "lo" accept
|
||||||
|
ct state established,related accept
|
||||||
|
ct state invalid drop
|
||||||
|
|
||||||
|
{% if chezlepro_firewall_allow_icmp | bool %}
|
||||||
|
ip protocol icmp accept
|
||||||
|
ip6 nexthdr icmpv6 accept
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if chezlepro_firewall_allow_ssh | bool %}
|
||||||
|
tcp dport {{ chezlepro_ssh_port }} accept
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% for port in chezlepro_firewall_extra_tcp_ports %}
|
||||||
|
tcp dport {{ port }} accept
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
{% for port in chezlepro_firewall_extra_udp_ports %}
|
||||||
|
udp dport {{ port }} accept
|
||||||
|
{% endfor %}
|
||||||
|
}
|
||||||
|
|
||||||
|
chain forward {
|
||||||
|
type filter hook forward priority 0; policy {{ chezlepro_firewall_forward_policy }};
|
||||||
|
}
|
||||||
|
|
||||||
|
chain output {
|
||||||
|
type filter hook output priority 0; policy {{ chezlepro_firewall_output_policy }};
|
||||||
|
}
|
||||||
|
}
|
||||||
3
roles/qemu_guest_agent/README.md
Normal file
3
roles/qemu_guest_agent/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle qemu_guest_agent
|
||||||
|
|
||||||
|
Installe et active qemu-guest-agent.
|
||||||
11
roles/qemu_guest_agent/tasks/main.yml
Normal file
11
roles/qemu_guest_agent/tasks/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Installer qemu-guest-agent
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: qemu-guest-agent
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Activer et démarrer qemu-guest-agent
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: qemu-guest-agent
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
3
roles/ssh_baseline/README.md
Normal file
3
roles/ssh_baseline/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle ssh_baseline
|
||||||
|
|
||||||
|
Déploie la configuration SSH de base.
|
||||||
4
roles/ssh_baseline/defaults/main.yml
Normal file
4
roles/ssh_baseline/defaults/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
chezlepro_ssh_password_authentication: "yes"
|
||||||
|
chezlepro_ssh_permit_root_login: "no"
|
||||||
|
chezlepro_ssh_pubkey_authentication: "yes"
|
||||||
11
roles/ssh_baseline/handlers/main.yml
Normal file
11
roles/ssh_baseline/handlers/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Validate and reload ssh
|
||||||
|
block:
|
||||||
|
- name: Valider la configuration SSH
|
||||||
|
ansible.builtin.command: sshd -t
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Recharger SSH
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: ssh
|
||||||
|
state: reloaded
|
||||||
28
roles/ssh_baseline/tasks/main.yml
Normal file
28
roles/ssh_baseline/tasks/main.yml
Normal file
|
|
@ -0,0 +1,28 @@
|
||||||
|
---
|
||||||
|
- name: Installer openssh-server
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name: openssh-server
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Créer le répertoire sshd_config.d
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/ssh/sshd_config.d
|
||||||
|
state: directory
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Déployer la configuration SSH Chezlepro
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 10-chezlepro.conf.j2
|
||||||
|
dest: /etc/ssh/sshd_config.d/10-chezlepro.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Validate and reload ssh
|
||||||
|
|
||||||
|
- name: Activer et démarrer SSH
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: ssh
|
||||||
|
enabled: true
|
||||||
|
state: started
|
||||||
8
roles/ssh_baseline/templates/10-chezlepro.conf.j2
Normal file
8
roles/ssh_baseline/templates/10-chezlepro.conf.j2
Normal file
|
|
@ -0,0 +1,8 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
PermitRootLogin {{ chezlepro_ssh_permit_root_login }}
|
||||||
|
PubkeyAuthentication {{ chezlepro_ssh_pubkey_authentication }}
|
||||||
|
PasswordAuthentication {{ chezlepro_ssh_password_authentication }}
|
||||||
|
KbdInteractiveAuthentication no
|
||||||
|
X11Forwarding no
|
||||||
|
UsePAM yes
|
||||||
3
roles/ssh_hardening/README.md
Normal file
3
roles/ssh_hardening/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle ssh_hardening
|
||||||
|
|
||||||
|
Ajoute des réglages SSH plus stricts.
|
||||||
9
roles/ssh_hardening/defaults/main.yml
Normal file
9
roles/ssh_hardening/defaults/main.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
chezlepro_ssh_port: 22
|
||||||
|
chezlepro_ssh_password_authentication: "yes"
|
||||||
|
chezlepro_ssh_permit_root_login: "no"
|
||||||
|
chezlepro_ssh_pubkey_authentication: "yes"
|
||||||
|
chezlepro_ssh_client_alive_interval: 300
|
||||||
|
chezlepro_ssh_client_alive_count_max: 2
|
||||||
|
chezlepro_ssh_max_auth_tries: 4
|
||||||
|
chezlepro_ssh_login_grace_time: "30s"
|
||||||
11
roles/ssh_hardening/handlers/main.yml
Normal file
11
roles/ssh_hardening/handlers/main.yml
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
---
|
||||||
|
- name: Validate and reload ssh
|
||||||
|
block:
|
||||||
|
- name: Valider la configuration SSH
|
||||||
|
ansible.builtin.command: sshd -t
|
||||||
|
changed_when: false
|
||||||
|
|
||||||
|
- name: Recharger SSH
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
name: ssh
|
||||||
|
state: reloaded
|
||||||
9
roles/ssh_hardening/tasks/main.yml
Normal file
9
roles/ssh_hardening/tasks/main.yml
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
---
|
||||||
|
- name: Déployer le hardening SSH additionnel
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 20-chezlepro-hardening.conf.j2
|
||||||
|
dest: /etc/ssh/sshd_config.d/20-chezlepro-hardening.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Validate and reload ssh
|
||||||
15
roles/ssh_hardening/templates/20-chezlepro-hardening.conf.j2
Normal file
15
roles/ssh_hardening/templates/20-chezlepro-hardening.conf.j2
Normal file
|
|
@ -0,0 +1,15 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
Port {{ chezlepro_ssh_port }}
|
||||||
|
PermitRootLogin {{ chezlepro_ssh_permit_root_login }}
|
||||||
|
PubkeyAuthentication {{ chezlepro_ssh_pubkey_authentication }}
|
||||||
|
PasswordAuthentication {{ chezlepro_ssh_password_authentication }}
|
||||||
|
KbdInteractiveAuthentication no
|
||||||
|
PermitEmptyPasswords no
|
||||||
|
X11Forwarding no
|
||||||
|
AllowTcpForwarding no
|
||||||
|
AllowAgentForwarding no
|
||||||
|
ClientAliveInterval {{ chezlepro_ssh_client_alive_interval }}
|
||||||
|
ClientAliveCountMax {{ chezlepro_ssh_client_alive_count_max }}
|
||||||
|
MaxAuthTries {{ chezlepro_ssh_max_auth_tries }}
|
||||||
|
LoginGraceTime {{ chezlepro_ssh_login_grace_time }}
|
||||||
3
roles/sudo_ansible/README.md
Normal file
3
roles/sudo_ansible/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle sudo_ansible
|
||||||
|
|
||||||
|
Configure sudo NOPASSWD pour le compte technique.
|
||||||
2
roles/sudo_ansible/defaults/main.yml
Normal file
2
roles/sudo_ansible/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_admin_user: ansible
|
||||||
23
roles/sudo_ansible/tasks/main.yml
Normal file
23
roles/sudo_ansible/tasks/main.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
- name: S'assurer que le groupe sudo existe
|
||||||
|
ansible.builtin.group:
|
||||||
|
name: sudo
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: S'assurer que le compte technique existe
|
||||||
|
ansible.builtin.user:
|
||||||
|
name: "{{ chezlepro_admin_user }}"
|
||||||
|
shell: /bin/bash
|
||||||
|
groups: sudo
|
||||||
|
append: true
|
||||||
|
create_home: true
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Déployer sudo NOPASSWD pour le compte technique
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 90-ansible.j2
|
||||||
|
dest: "/etc/sudoers.d/90-{{ chezlepro_admin_user }}"
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0440"
|
||||||
|
validate: "visudo -cf %s"
|
||||||
2
roles/sudo_ansible/templates/90-ansible.j2
Normal file
2
roles/sudo_ansible/templates/90-ansible.j2
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
{{ chezlepro_admin_user }} ALL=(ALL) NOPASSWD:ALL
|
||||||
3
roles/sysctl_hardening/README.md
Normal file
3
roles/sysctl_hardening/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle sysctl_hardening
|
||||||
|
|
||||||
|
Déploie des paramètres sysctl raisonnables.
|
||||||
29
roles/sysctl_hardening/defaults/main.yml
Normal file
29
roles/sysctl_hardening/defaults/main.yml
Normal file
|
|
@ -0,0 +1,29 @@
|
||||||
|
---
|
||||||
|
chezlepro_sysctl_apply: true
|
||||||
|
chezlepro_sysctl_hardening_values:
|
||||||
|
fs.protected_hardlinks: 1
|
||||||
|
fs.protected_symlinks: 1
|
||||||
|
fs.protected_fifos: 2
|
||||||
|
fs.protected_regular: 2
|
||||||
|
fs.suid_dumpable: 0
|
||||||
|
kernel.core_uses_pid: 1
|
||||||
|
kernel.ctrl-alt-del: 0
|
||||||
|
kernel.dmesg_restrict: 1
|
||||||
|
kernel.kptr_restrict: 2
|
||||||
|
kernel.perf_event_paranoid: 2
|
||||||
|
kernel.randomize_va_space: 2
|
||||||
|
net.ipv4.conf.all.accept_redirects: 0
|
||||||
|
net.ipv4.conf.default.accept_redirects: 0
|
||||||
|
net.ipv6.conf.all.accept_redirects: 0
|
||||||
|
net.ipv6.conf.default.accept_redirects: 0
|
||||||
|
net.ipv4.conf.all.send_redirects: 0
|
||||||
|
net.ipv4.conf.default.send_redirects: 0
|
||||||
|
net.ipv4.conf.all.accept_source_route: 0
|
||||||
|
net.ipv4.conf.default.accept_source_route: 0
|
||||||
|
net.ipv6.conf.all.accept_source_route: 0
|
||||||
|
net.ipv6.conf.default.accept_source_route: 0
|
||||||
|
net.ipv4.icmp_echo_ignore_broadcasts: 1
|
||||||
|
net.ipv4.icmp_ignore_bogus_error_responses: 1
|
||||||
|
net.ipv4.tcp_syncookies: 1
|
||||||
|
net.ipv4.conf.all.log_martians: 1
|
||||||
|
net.ipv4.conf.default.log_martians: 1
|
||||||
4
roles/sysctl_hardening/handlers/main.yml
Normal file
4
roles/sysctl_hardening/handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: Reload sysctl
|
||||||
|
ansible.builtin.command: sysctl --system
|
||||||
|
changed_when: true
|
||||||
10
roles/sysctl_hardening/tasks/main.yml
Normal file
10
roles/sysctl_hardening/tasks/main.yml
Normal file
|
|
@ -0,0 +1,10 @@
|
||||||
|
---
|
||||||
|
- name: Déployer les paramètres sysctl de hardening
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99-chezlepro-hardening.conf.j2
|
||||||
|
dest: /etc/sysctl.d/99-chezlepro-hardening.conf
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
notify: Reload sysctl
|
||||||
|
when: chezlepro_sysctl_apply | bool
|
||||||
|
|
@ -0,0 +1,5 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
{% for key, value in chezlepro_sysctl_hardening_values | dictsort %}
|
||||||
|
{{ key }} = {{ value }}
|
||||||
|
{% endfor %}
|
||||||
3
roles/systemd_ssh_auto/README.md
Normal file
3
roles/systemd_ssh_auto/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle systemd_ssh_auto
|
||||||
|
|
||||||
|
Désactive systemd.ssh_auto pour éviter le bruit SSH/VSOCK.
|
||||||
2
roles/systemd_ssh_auto/defaults/main.yml
Normal file
2
roles/systemd_ssh_auto/defaults/main.yml
Normal file
|
|
@ -0,0 +1,2 @@
|
||||||
|
---
|
||||||
|
chezlepro_disable_systemd_ssh_auto: true
|
||||||
4
roles/systemd_ssh_auto/handlers/main.yml
Normal file
4
roles/systemd_ssh_auto/handlers/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
- name: Update grub
|
||||||
|
ansible.builtin.command: update-grub
|
||||||
|
changed_when: true
|
||||||
17
roles/systemd_ssh_auto/tasks/main.yml
Normal file
17
roles/systemd_ssh_auto/tasks/main.yml
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
---
|
||||||
|
- name: Déployer le paramètre GRUB pour désactiver systemd.ssh_auto
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 99-chezlepro-systemd-ssh-auto.cfg.j2
|
||||||
|
dest: /etc/default/grub.d/99-chezlepro-systemd-ssh-auto.cfg
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
when: chezlepro_disable_systemd_ssh_auto | bool
|
||||||
|
notify: Update grub
|
||||||
|
|
||||||
|
- name: Supprimer le paramètre si désactivé
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/default/grub.d/99-chezlepro-systemd-ssh-auto.cfg
|
||||||
|
state: absent
|
||||||
|
when: not (chezlepro_disable_systemd_ssh_auto | bool)
|
||||||
|
notify: Update grub
|
||||||
|
|
@ -0,0 +1,2 @@
|
||||||
|
# Managed by Ansible — Set-OPS
|
||||||
|
GRUB_CMDLINE_LINUX="${GRUB_CMDLINE_LINUX} systemd.ssh_auto=no"
|
||||||
3
roles/template_cleanup/README.md
Normal file
3
roles/template_cleanup/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle template_cleanup
|
||||||
|
|
||||||
|
Nettoyage final avant conversion Proxmox.
|
||||||
3
roles/template_cleanup/defaults/main.yml
Normal file
3
roles/template_cleanup/defaults/main.yml
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
---
|
||||||
|
confirm_template_cleanup: false
|
||||||
|
chezlepro_admin_user: ansible
|
||||||
63
roles/template_cleanup/tasks/main.yml
Normal file
63
roles/template_cleanup/tasks/main.yml
Normal file
|
|
@ -0,0 +1,63 @@
|
||||||
|
---
|
||||||
|
- name: Refuser le nettoyage sans confirmation explicite
|
||||||
|
ansible.builtin.assert:
|
||||||
|
that:
|
||||||
|
- confirm_template_cleanup | bool
|
||||||
|
fail_msg: "Nettoyage refusé. Relancer avec -e confirm_template_cleanup=true"
|
||||||
|
|
||||||
|
- name: Nettoyer cloud-init
|
||||||
|
ansible.builtin.command: cloud-init clean --logs
|
||||||
|
changed_when: true
|
||||||
|
|
||||||
|
- name: Nettoyer le cache APT
|
||||||
|
ansible.builtin.apt:
|
||||||
|
clean: true
|
||||||
|
|
||||||
|
- name: Supprimer les paquets devenus inutiles
|
||||||
|
ansible.builtin.apt:
|
||||||
|
autoremove: true
|
||||||
|
|
||||||
|
- name: Rotation des journaux systemd
|
||||||
|
ansible.builtin.command: journalctl --rotate
|
||||||
|
changed_when: true
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Vider les anciens journaux systemd
|
||||||
|
ansible.builtin.command: journalctl --vacuum-time=1s
|
||||||
|
changed_when: true
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Vider /etc/machine-id
|
||||||
|
ansible.builtin.copy:
|
||||||
|
dest: /etc/machine-id
|
||||||
|
content: ""
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0444"
|
||||||
|
|
||||||
|
- name: Supprimer l'ancien machine-id D-Bus
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /var/lib/dbus/machine-id
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
- name: Recréer le lien D-Bus vers /etc/machine-id
|
||||||
|
ansible.builtin.file:
|
||||||
|
src: /etc/machine-id
|
||||||
|
dest: /var/lib/dbus/machine-id
|
||||||
|
state: link
|
||||||
|
force: true
|
||||||
|
|
||||||
|
- name: Supprimer les historiques shell
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: "{{ item }}"
|
||||||
|
state: absent
|
||||||
|
loop:
|
||||||
|
- /root/.bash_history
|
||||||
|
- "/home/{{ chezlepro_admin_user }}/.bash_history"
|
||||||
|
failed_when: false
|
||||||
|
|
||||||
|
- name: Message final
|
||||||
|
ansible.builtin.debug:
|
||||||
|
msg:
|
||||||
|
- "Nettoyage final terminé."
|
||||||
|
- "Éteindre la VM puis convertir en template Proxmox."
|
||||||
3
roles/unattended_upgrades/README.md
Normal file
3
roles/unattended_upgrades/README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Rôle unattended_upgrades
|
||||||
|
|
||||||
|
Configure les mises à jour automatiques de sécurité.
|
||||||
4
roles/unattended_upgrades/defaults/main.yml
Normal file
4
roles/unattended_upgrades/defaults/main.yml
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
---
|
||||||
|
chezlepro_unattended_upgrades_enabled: true
|
||||||
|
chezlepro_unattended_remove_unused_dependencies: true
|
||||||
|
chezlepro_unattended_automatic_reboot: false
|
||||||
23
roles/unattended_upgrades/tasks/main.yml
Normal file
23
roles/unattended_upgrades/tasks/main.yml
Normal file
|
|
@ -0,0 +1,23 @@
|
||||||
|
---
|
||||||
|
- name: Installer unattended-upgrades
|
||||||
|
ansible.builtin.apt:
|
||||||
|
name:
|
||||||
|
- unattended-upgrades
|
||||||
|
- apt-listchanges
|
||||||
|
state: present
|
||||||
|
|
||||||
|
- name: Configurer les mises à jour automatiques
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 20auto-upgrades.j2
|
||||||
|
dest: /etc/apt/apt.conf.d/20auto-upgrades
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Configurer unattended-upgrades
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: 50unattended-upgrades.j2
|
||||||
|
dest: /etc/apt/apt.conf.d/50unattended-upgrades
|
||||||
|
owner: root
|
||||||
|
group: root
|
||||||
|
mode: "0644"
|
||||||
4
roles/unattended_upgrades/templates/20auto-upgrades.j2
Normal file
4
roles/unattended_upgrades/templates/20auto-upgrades.j2
Normal file
|
|
@ -0,0 +1,4 @@
|
||||||
|
// Managed by Ansible — Set-OPS
|
||||||
|
APT::Periodic::Update-Package-Lists "{{ 1 if chezlepro_unattended_upgrades_enabled | bool else 0 }}";
|
||||||
|
APT::Periodic::Unattended-Upgrade "{{ 1 if chezlepro_unattended_upgrades_enabled | bool else 0 }}";
|
||||||
|
APT::Periodic::AutocleanInterval "7";
|
||||||
11
roles/unattended_upgrades/templates/50unattended-upgrades.j2
Normal file
11
roles/unattended_upgrades/templates/50unattended-upgrades.j2
Normal file
|
|
@ -0,0 +1,11 @@
|
||||||
|
// Managed by Ansible — Set-OPS
|
||||||
|
|
||||||
|
Unattended-Upgrade::Origins-Pattern {
|
||||||
|
"origin=Debian,codename=${distro_codename}-security,label=Debian-Security";
|
||||||
|
};
|
||||||
|
|
||||||
|
Unattended-Upgrade::Remove-Unused-Kernel-Packages "true";
|
||||||
|
Unattended-Upgrade::Remove-New-Unused-Dependencies "{{ 'true' if chezlepro_unattended_remove_unused_dependencies | bool else 'false' }}";
|
||||||
|
Unattended-Upgrade::Remove-Unused-Dependencies "{{ 'true' if chezlepro_unattended_remove_unused_dependencies | bool else 'false' }}";
|
||||||
|
Unattended-Upgrade::Automatic-Reboot "{{ 'true' if chezlepro_unattended_automatic_reboot | bool else 'false' }}";
|
||||||
|
Unattended-Upgrade::SyslogEnable "true";
|
||||||
Reference in a new issue