266 lines
7.4 KiB
Markdown
266 lines
7.4 KiB
Markdown
# Ansible Minecraft Spigot Server
|
|
|
|
Ce projet Ansible permet d'installer et de gérer automatiquement un serveur Minecraft Spigot avec toutes les fonctionnalités nécessaires pour un environnement de production.
|
|
|
|
## 🚀 Fonctionnalités
|
|
|
|
- **Installation automatisée** de Minecraft Spigot version 1.21.6
|
|
- **Durcissement de sécurité** du serveur (SSH, Firewall, Fail2ban)
|
|
- **Installation Java** automatique et optimisée
|
|
- **Système de sauvegarde** complet (quotidien, hebdomadaire, mensuel)
|
|
- **Mises à jour automatiques** de Spigot
|
|
- **Gestion des plugins** et des administrateurs
|
|
- **Surveillance et logs** avec rotation automatique
|
|
- **CI/CD intégré** avec Gitea Actions
|
|
|
|
## 📋 Prérequis
|
|
|
|
### Serveurs cibles
|
|
- **OS supportés** : Debian 10/11/12/13 ou Ubuntu LTS
|
|
- **Accès SSH** configuré avec l'utilisateur `ansible`
|
|
- **Privilèges sudo** pour l'utilisateur ansible
|
|
- **Python 3.8+** installé sur les cibles
|
|
|
|
### Machine de contrôle
|
|
- **Ansible 2.10+**
|
|
- **Python 3.8+**
|
|
- **Collections Ansible** (installées via requirements.yml)
|
|
|
|
## 🛠️ Installation
|
|
|
|
### 1. Cloner le repository
|
|
```bash
|
|
git clone https://gitea.tips-of-mine.com/Tips-Of-Mine/Ansible-Minecraft-Serveur.git
|
|
cd Ansible-Minecraft-Serveur
|
|
```
|
|
|
|
### 2. Installer les dépendances
|
|
```bash
|
|
# Installation des collections Ansible
|
|
ansible-galaxy collection install -r requirements.yml
|
|
|
|
# Installation de Python (si nécessaire)
|
|
python3 -m pip install ansible
|
|
```
|
|
|
|
### 3. Configuration des inventaires
|
|
|
|
#### Staging
|
|
Éditer `inventories/staging/hosts.yml` et `inventories/staging/group_vars/all.yml`
|
|
|
|
#### Production
|
|
Éditer `inventories/production/hosts.yml` et `inventories/production/group_vars/all.yml`
|
|
|
|
### 4. Configuration des secrets
|
|
|
|
#### Pour Gitea CI/CD
|
|
Configurer ces secrets dans Gitea :
|
|
- `ANSIBLE_SSH_PRIVATE_KEY` : Clé SSH privée (base64)
|
|
- `MINECRAFT_RCON_PASSWORD` : Mot de passe RCON
|
|
- `STAGING_HOST` : Adresse du serveur staging
|
|
- `PRODUCTION_HOST` : Adresse du serveur production
|
|
|
|
## 📚 Structure du projet
|
|
|
|
```
|
|
Ansible-Minecraft-Serveur/
|
|
├── README.md # Ce fichier
|
|
├── requirements.yml # Collections Ansible requises
|
|
├── secrets # Template des secrets
|
|
├── site.yml # Playbook principal
|
|
├── .gitea/workflows/ci.yml # Pipeline CI/CD
|
|
├── inventories/ # Inventaires par environnement
|
|
│ ├── production/ # Configuration production
|
|
│ └── staging/ # Configuration staging
|
|
└── roles/ # Rôles Ansible
|
|
├── 01-server_hardening/ # Durcissement serveur
|
|
├── 02-installation-java/ # Installation Java
|
|
├── 03-Installation-minecraft/ # Installation Minecraft
|
|
├── 04-backups/ # Système de sauvegarde
|
|
└── 05-Update/ # Gestion des mises à jour
|
|
```
|
|
|
|
## 🚀 Utilisation
|
|
|
|
### Déploiement complet
|
|
|
|
#### Environnement Staging
|
|
```bash
|
|
# Vérification de la syntaxe
|
|
ansible-playbook --syntax-check site.yml -i inventories/staging/hosts.yml
|
|
|
|
# Mode dry-run
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml --check --diff
|
|
|
|
# Déploiement réel
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml
|
|
```
|
|
|
|
#### Environnement Production
|
|
```bash
|
|
# Mode dry-run obligatoire en production
|
|
ansible-playbook site.yml -i inventories/production/hosts.yml --check --diff
|
|
|
|
# Déploiement réel (après validation)
|
|
ansible-playbook site.yml -i inventories/production/hosts.yml
|
|
```
|
|
|
|
### Déploiement par rôle
|
|
|
|
#### Durcissement uniquement
|
|
```bash
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml --tags hardening
|
|
```
|
|
|
|
#### Installation/Mise à jour Minecraft
|
|
```bash
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml --tags minecraft
|
|
```
|
|
|
|
#### Configuration sauvegardes
|
|
```bash
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml --tags backup
|
|
```
|
|
|
|
## 🔧 Configuration avancée
|
|
|
|
### Variables importantes
|
|
|
|
#### Minecraft
|
|
```yaml
|
|
minecraft_version: "1.21.6" # Version Spigot
|
|
minecraft_max_memory: "4G" # RAM maximum
|
|
minecraft_min_memory: "2G" # RAM minimum
|
|
minecraft_port: 25565 # Port serveur
|
|
minecraft_rcon_port: 25575 # Port RCON
|
|
```
|
|
|
|
#### Sécurité
|
|
```yaml
|
|
firewall_enabled: true # Activation UFW
|
|
fail2ban_enabled: true # Activation Fail2ban
|
|
hardening_enabled: true # Durcissement complet
|
|
ssh_port: 22 # Port SSH
|
|
```
|
|
|
|
#### Sauvegardes
|
|
```yaml
|
|
backup_enabled: true # Activation sauvegardes
|
|
backup_retention_daily: 7 # Rétention quotidienne
|
|
backup_retention_weekly: 4 # Rétention hebdomadaire
|
|
backup_retention_monthly: 6 # Rétention mensuelle
|
|
```
|
|
|
|
### Ajout d'administrateurs Minecraft
|
|
|
|
Dans `group_vars/all.yml` :
|
|
```yaml
|
|
minecraft_admins:
|
|
- name: "PlayerName"
|
|
uuid: "player-uuid-here"
|
|
level: 4
|
|
bypass_limit: false
|
|
```
|
|
|
|
### Installation de plugins
|
|
|
|
```yaml
|
|
minecraft_plugins:
|
|
- name: "WorldEdit"
|
|
url: "https://example.com/worldedit.jar"
|
|
- name: "Vault"
|
|
url: "https://example.com/vault.jar"
|
|
```
|
|
|
|
## 🔍 Monitoring et maintenance
|
|
|
|
### Logs importants
|
|
- **Serveur Minecraft** : `/opt/minecraft/server/logs/`
|
|
- **Système** : `/var/log/syslog`
|
|
- **SSH** : `/var/log/auth.log`
|
|
- **Fail2ban** : `/var/log/fail2ban.log`
|
|
|
|
### Commandes utiles
|
|
|
|
#### Status du serveur
|
|
```bash
|
|
systemctl status minecraft
|
|
```
|
|
|
|
#### Connexion RCON
|
|
```bash
|
|
/opt/minecraft/tools/mcrcon/mcrcon -H localhost -P 25575 -p votre_mot_de_passe
|
|
```
|
|
|
|
#### Sauvegarde manuelle
|
|
```bash
|
|
/usr/local/bin/minecraft-backup-daily.sh
|
|
```
|
|
|
|
#### Restauration
|
|
```bash
|
|
/usr/local/bin/minecraft-restore.sh daily minecraft-daily-20240127_020000
|
|
```
|
|
|
|
## 🔄 Mises à jour
|
|
|
|
### Automatiques
|
|
Les mises à jour sont vérifiées selon la planification définie dans les crons.
|
|
|
|
### Manuelles
|
|
```bash
|
|
ansible-playbook site.yml -i inventories/production/hosts.yml --tags update
|
|
```
|
|
|
|
## 🐛 Dépannage
|
|
|
|
### Problèmes courants
|
|
|
|
#### Le serveur ne démarre pas
|
|
1. Vérifier les logs : `journalctl -u minecraft -f`
|
|
2. Vérifier l'EULA : `/opt/minecraft/server/eula.txt`
|
|
3. Vérifier la RAM disponible : `free -h`
|
|
|
|
#### Compilation Spigot échoue
|
|
1. Vérifier Java : `java -version`
|
|
2. Vérifier l'espace disque : `df -h`
|
|
3. Vérifier les logs de compilation
|
|
|
|
#### Connexion SSH échoue
|
|
1. Vérifier le pare-feu : `ufw status`
|
|
2. Vérifier les clés SSH
|
|
3. Vérifier Fail2ban : `fail2ban-client status sshd`
|
|
|
|
### Logs de debug
|
|
```bash
|
|
# Activation du mode verbose
|
|
ansible-playbook site.yml -i inventories/staging/hosts.yml -vvv
|
|
```
|
|
|
|
## 🤝 Contribution
|
|
|
|
1. Fork le projet
|
|
2. Créer une branche feature (`git checkout -b feature/amazing-feature`)
|
|
3. Commit les changements (`git commit -m 'Add amazing feature'`)
|
|
4. Push vers la branche (`git push origin feature/amazing-feature`)
|
|
5. Créer une Pull Request
|
|
|
|
## 📝 Licence
|
|
|
|
Ce projet est sous licence MIT. Voir le fichier `LICENSE` pour plus de détails.
|
|
|
|
## 🆘 Support
|
|
|
|
- **Issues** : [Gitea Issues](https://gitea.tips-of-mine.com/Tips-Of-Mine/Ansible-Minecraft-Serveur/issues)
|
|
- **Wiki** : [Documentation détaillée](https://gitea.tips-of-mine.com/Tips-Of-Mine/Ansible-Minecraft-Serveur/wiki)
|
|
- **Discussions** : [Forum du projet](https://gitea.tips-of-mine.com/Tips-Of-Mine/Ansible-Minecraft-Serveur/discussions)
|
|
|
|
## 🙏 Remerciements
|
|
|
|
- Équipe Ansible pour l'excellente plateforme
|
|
- Communauté Spigot pour le serveur
|
|
- Contributeurs du projet
|
|
|
|
---
|
|
|
|
**Made with ❤️ for Minecraft communities** |