You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

767 lines
22 KiB

# 🚀 Git Pusher for Splunk
**Version 2.1** | Application Splunk pour déployer vos applications vers Git et le Search Head Cluster
---
## 📋 Table des matières
- [Présentation](#-présentation)
- [Fonctionnalités](#-fonctionnalités)
- [Architecture](#-architecture)
- [Installation - Serveur Source](#-installation---serveur-source)
- [Installation - SH Deployer Agent](#-installation---sh-deployer-agent)
- [Configuration](#-configuration)
- [Configuration HTTPS](#-configuration-https)
- [Système de Licence](#-système-de-licence)
- [Utilisation](#-utilisation)
- [Sécurité](#-sécurité)
- [Personnalisation du Dashboard](#-personnalisation-du-dashboard)
- [Dépannage](#-dépannage)
- [API Reference](#-api-reference)
- [Changelog](#-changelog)
- [Support](#-support)
---
## 🎯 Présentation
**Git Pusher** est une application Splunk Enterprise qui permet de :
1. **Versionner** vos applications Splunk dans un repository Git
2. **Déployer automatiquement** vers un Search Head Cluster via le SH Deployer
Le workflow complet en un clic :
```
Splunk Source → Push Git → Pull SH Deployer → Apply Bundle → Search Head Cluster
```
Idéal pour :
- 📦 Sauvegarder vos configurations Splunk
- 🔄 Versionner vos dashboards et applications
- 👥 Collaborer en équipe sur les développements Splunk
- 🚀 Mettre en place un workflow CI/CD pour Splunk
- 🎯 Déployer automatiquement vers votre Search Head Cluster
---
## ✨ Fonctionnalités
| Fonctionnalité | Description |
|----------------|-------------|
| **Push vers Git** | Déployez une ou plusieurs applications Splunk vers votre repository Git |
| **Déploiement SH Cluster** | Déploiement automatique vers le Search Head Cluster après le push Git |
| **Interface moderne** | Dashboard intuitif avec sélection visuelle des applications |
| **Multi-repository** | Support de GitHub, GitLab, Gitea, Bitbucket et tout serveur Git |
| **Support HTTPS** | Communication sécurisée avec certificats SSL |
| **Système de licence** | Gestion par fichier `.lic` sécurisé |
| **Credentials sécurisés** | Chiffrement des mots de passe Splunk |
| **Logs détaillés** | Traçabilité complète des opérations |
---
## 🏗 Architecture
```
┌─────────────────────────────────────────────────────────────────┐
│ SERVEUR SOURCE │
│ ┌─────────────┐ ┌─────────────────────────────────────┐ │
│ │ Splunk │────▶│ Git Pusher Server (:9999) │ │
│ │ Dashboard │ │ 1. Push apps vers Git │ │
│ │ (HTTPS) │ │ 2. Appelle le SH Deployer Agent │ │
│ └─────────────┘ └──────────────────┬──────────────────┘ │
└─────────────────────────────────────────┼───────────────────────┘
│ HTTPS (:9998)
┌─────────────────────────────────────────────────────────────────┐
│ SH DEPLOYER │
│ ┌─────────────────────────────────────────────────────────┐ │
│ │ Deployer Agent (:9998) │ │
│ │ 1. Git pull dans /opt/splunk/etc/shcluster/apps/ │ │
│ │ 2. Exécute: splunk apply shcluster-bundle │ │
│ └─────────────────────────────────────────────────────────┘ │
└─────────────────────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────────────────────┐
│ SEARCH HEAD CLUSTER │
│ ┌───────────┐ ┌───────────┐ ┌───────────┐ │
│ │ SH1 │ │ SH2 │ │ SH3 │ │
│ └───────────┘ └───────────┘ └───────────┘ │
└─────────────────────────────────────────────────────────────────┘
```
### Structure des fichiers
```
SERVEUR SOURCE - pusher_app_prem/
├── bin/
│ ├── git_pusher.py # Serveur HTTP/HTTPS principal (port 9999)
│ ├── license_validator.py # Validation des licences
│ ├── license_generator.py # Génération des licences (vendeur)
│ ├── credentials_manager.py # Gestion sécurisée des credentials
│ └── start_git_pusher.sh # Script de démarrage
├── appserver/static/
│ ├── git_pusher.js # Logique JavaScript principale
│ └── license_validation.js # Interface de gestion des licences
├── default/data/ui/views/
│ └── git_pusher_-_deploy_applications.xml # Dashboard principal
├── local/
│ ├── license.lic # Fichier de licence (après activation)
│ ├── .credentials # Credentials chiffrés
│ ├── .key # Clé de chiffrement
│ └── certs/ # Certificats SSL
│ ├── server.crt
│ └── server.key
└── README.md
SH DEPLOYER - deployer_agent/
├── bin/
│ ├── deployer_agent.py # Agent de déploiement (port 9998)
│ └── start_deployer_agent.sh # Script de démarrage
└── local/
└── certs/ # Certificats SSL
├── server.crt
└── server.key
```
---
## 📥 Installation - Serveur Source
### Prérequis
- Splunk Enterprise 8.x ou supérieur
- Python 3.7+
- Git installé sur le serveur (`yum install git` ou `apt install git`)
- OpenSSL (pour la génération des certificats HTTPS)
- Accès réseau vers votre repository Git
### Étapes d'installation
#### 1. Extraire l'application
```bash
# Copier l'application dans Splunk
cp -r pusher_app_prem /opt/splunk/etc/apps/
# Définir les permissions
chown -R splunk:splunk /opt/splunk/etc/apps/pusher_app_prem
chmod +x /opt/splunk/etc/apps/pusher_app_prem/bin/*.sh
```
#### 2. Configurer les credentials Splunk
```bash
cd /opt/splunk/etc/apps/pusher_app_prem/bin/
./start_git_pusher.sh credentials setup
```
```
==================================================
Git Pusher - Credentials Setup
==================================================
Splunk Username [admin]: admin
Splunk Password: ********
Confirm Password: ********
✓ Credentials saved securely!
```
#### 3. Configurer HTTPS (si Splunk est en HTTPS)
```bash
# Créer le dossier des certificats
mkdir -p /opt/splunk/etc/apps/pusher_app_prem/local/certs
# Générer un certificat auto-signé (valide 365 jours)
openssl req -x509 -newkey rsa:4096 \
-keyout /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key \
-out /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.crt \
-days 365 -nodes -subj "/CN=git-pusher"
# Définir les permissions
chmod 600 /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key
chown -R splunk:splunk /opt/splunk/etc/apps/pusher_app_prem/local/certs/
```
#### 4. Démarrer le serveur Git Pusher
```bash
./start_git_pusher.sh start
```
#### 5. Ouvrir le firewall (si nécessaire)
```bash
# FirewallD
sudo firewall-cmd --add-port=9999/tcp --permanent
sudo firewall-cmd --reload
# UFW
sudo ufw allow 9999/tcp
```
#### 6. Redémarrer Splunk
```bash
/opt/splunk/bin/splunk restart
```
#### 7. Accepter le certificat dans le navigateur
1. Ouvrir : `https://VOTRE_IP_SPLUNK:9999/health`
2. Accepter le certificat auto-signé
3. Rafraîchir le dashboard (Ctrl+Shift+R)
---
## 📥 Installation - SH Deployer Agent
### Sur le serveur SH Deployer
#### 1. Créer l'application
```bash
# Créer les dossiers
mkdir -p /opt/splunk/etc/apps/deployer_agent/bin
mkdir -p /opt/splunk/etc/apps/deployer_agent/local/certs
# Copier les fichiers
cp deployer_agent.py /opt/splunk/etc/apps/deployer_agent/bin/
cp start_deployer_agent.sh /opt/splunk/etc/apps/deployer_agent/bin/
# Rendre exécutable
chmod +x /opt/splunk/etc/apps/deployer_agent/bin/start_deployer_agent.sh
```
#### 2. Configurer le token d'authentification
```bash
nano /opt/splunk/etc/apps/deployer_agent/bin/deployer_agent.py
```
Modifier la ligne `AUTH_TOKEN` :
```python
AUTH_TOKEN = "votre_token_secret_personnalise"
```
#### 3. Configurer le Search Head Captain
Dans le même fichier, trouver la fonction `apply_shcluster_bundle` et modifier l'IP du captain :
```python
target_uri = "https://IP_DU_CAPTAIN:8089"
```
#### 4. Générer les certificats SSL
```bash
cd /opt/splunk/etc/apps/deployer_agent/bin/
./start_deployer_agent.sh gencerts
```
#### 5. Définir les permissions
```bash
chown -R splunk:splunk /opt/splunk/etc/apps/deployer_agent
```
#### 6. Ouvrir le firewall
```bash
sudo firewall-cmd --add-port=9998/tcp --permanent
sudo firewall-cmd --reload
```
#### 7. Démarrer l'agent
```bash
./start_deployer_agent.sh start
```
#### 8. Vérifier le statut
```bash
./start_deployer_agent.sh status
```
#### 9. Accepter le certificat
Ouvrir dans un navigateur : `https://IP_SH_DEPLOYER:9998/health`
Accepter le certificat auto-signé.
---
## ⚙️ Configuration
### Commandes Git Pusher (Serveur Source)
```bash
cd /opt/splunk/etc/apps/pusher_app_prem/bin/
# Démarrer le serveur
./start_git_pusher.sh start
# Arrêter le serveur
./start_git_pusher.sh stop
# Redémarrer le serveur
./start_git_pusher.sh restart
# Voir le statut
./start_git_pusher.sh status
# Voir les logs
./start_git_pusher.sh logs
./start_git_pusher.sh logs -f # Mode follow
# Gestion des credentials
./start_git_pusher.sh credentials setup
./start_git_pusher.sh credentials status
./start_git_pusher.sh credentials delete
```
### Commandes Deployer Agent (SH Deployer)
```bash
cd /opt/splunk/etc/apps/deployer_agent/bin/
# Démarrer l'agent
./start_deployer_agent.sh start
# Arrêter l'agent
./start_deployer_agent.sh stop
# Redémarrer l'agent
./start_deployer_agent.sh restart
# Voir le statut
./start_deployer_agent.sh status
# Voir les logs
./start_deployer_agent.sh logs
./start_deployer_agent.sh logs -f
# Générer les certificats SSL
./start_deployer_agent.sh gencerts
# Tester la connexion
./start_deployer_agent.sh test
```
### Configuration du SH Deployer dans l'interface
1. Ouvrir le dashboard Git Pusher
2. Cliquer sur **⚙️ Configure** dans la section "Deploy to Search Head Cluster"
3. Remplir :
- **Host** : IP du SH Deployer (ex: 10.10.40.14)
- **Port** : 9998
- **Token** : Le même token que dans `deployer_agent.py`
4. Cliquer sur **Save & Test**
---
## 🔒 Configuration HTTPS
### Git Pusher Server (Port 9999)
```bash
mkdir -p /opt/splunk/etc/apps/pusher_app_prem/local/certs
openssl req -x509 -newkey rsa:4096 \
-keyout /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key \
-out /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.crt \
-days 365 -nodes -subj "/CN=git-pusher"
chmod 600 /opt/splunk/etc/apps/pusher_app_prem/local/certs/server.key
chown -R splunk:splunk /opt/splunk/etc/apps/pusher_app_prem/local/certs/
```
### Deployer Agent (Port 9998)
```bash
mkdir -p /opt/splunk/etc/apps/deployer_agent/local/certs
openssl req -x509 -newkey rsa:4096 \
-keyout /opt/splunk/etc/apps/deployer_agent/local/certs/server.key \
-out /opt/splunk/etc/apps/deployer_agent/local/certs/server.crt \
-days 365 -nodes -subj "/CN=deployer-agent"
chmod 600 /opt/splunk/etc/apps/deployer_agent/local/certs/server.key
chown -R splunk:splunk /opt/splunk/etc/apps/deployer_agent/local/certs/
```
### Vérifier HTTPS
```bash
# Git Pusher
curl -k https://localhost:9999/health
# Deployer Agent
curl -k https://localhost:9998/health
```
---
## 🔐 Système de Licence
Git Pusher utilise un système de licence par fichier `.lic` pour activer les fonctionnalités.
### Types de licences
| Type | Durée | Apps max | Pushes/jour | Fonctionnalités |
|------|-------|----------|-------------|-----------------|
| **Trial** | 14 jours | 3 | 5 | Push basique |
| **Starter** | 1 an | 10 | 50 | + Push programmé |
| **Professional** | 1 an | Illimité | Illimité | + Multi-repo, Support prioritaire |
| **Enterprise** | 1 an | Illimité | Illimité | + SH Cluster deployment, API |
### Activer une licence
1. Ouvrir le dashboard Git Pusher
2. Glisser-déposer le fichier `.lic`
3. Cliquer sur "Activer"
---
## 📖 Utilisation
### Workflow complet : Push Git + Déploiement SH Cluster
1. **Ouvrir le dashboard** Git Pusher
2. **Sélectionner les applications** à déployer
3. **Configurer Git** :
- Repository URL : `https://github.com/user/repo.git`
- Branch : `main`
- Token : Personal Access Token
4. **Activer le déploiement SH Cluster** :
- Cocher "Enable automatic deployment"
- (Optionnel) Remplir les credentials Splunk si différents de l'admin par défaut
5. **Cliquer sur "Deploy to Git"**
Le processus automatique :
```
✅ Push vers Git
✅ Pull sur le SH Deployer
✅ Apply shcluster-bundle
✅ Mise à jour du Search Head Cluster
```
### Obtenir un token Git
#### GitHub
1. Settings → Developer settings → Personal access tokens
2. Generate new token
3. Cocher : `repo` (Full control)
#### GitLab
1. Preferences → Access Tokens
2. Create personal access token
3. Scopes : `write_repository`
#### Gitea
1. Settings → Applications → Generate New Token
2. Permissions : `repository: write`
---
## 🔒 Sécurité
### Credentials Splunk
- **Chiffrés** avec une clé dérivée de l'ID machine
- **Stockés** dans un fichier avec permissions `600`
- **Jamais visibles** en clair
### Communication HTTPS
- SSL/TLS entre tous les composants
- Certificats auto-signés supportés
- Validation du token d'authentification
### Token Deployer Agent
- Authentification par token entre Git Pusher et Deployer Agent
- Token configurable dans les deux composants
- Doit être identique des deux côtés
### Bonnes pratiques
1. ✅ Utiliser HTTPS pour tous les composants
2. ✅ Changer le token par défaut du Deployer Agent
3. ✅ Utiliser des tokens Git avec permissions minimales
4. ✅ Restreindre l'accès réseau au port 9998/9999
5. ✅ Renouveler les certificats régulièrement
---
## 🎨 Personnalisation du Dashboard
### Masquer les boutons d'édition
```bash
nano /opt/splunk/etc/apps/pusher_app_prem/default/data/ui/views/git_pusher_-_deploy_applications.xml
```
Modifier la première ligne :
```xml
<dashboard version="1.1" script="license_validation.js, git_pusher.js" hideEdit="true" hideExport="true">
```
### Options disponibles
| Attribut | Description |
|----------|-------------|
| `hideEdit="true"` | Masque le bouton "Modifier" |
| `hideExport="true"` | Masque le bouton "Exporter" |
| `hideTitle="true"` | Masque le titre du dashboard |
| `hideSplunkBar="true"` | Masque la barre Splunk en haut |
| `hideAppBar="true"` | Masque la barre de l'application |
| `hideFooter="true"` | Masque le footer |
### Appliquer les changements
```bash
rm -rf /opt/splunk/var/run/splunk/appserver/*
/opt/splunk/bin/splunk restart
```
---
## 🔧 Dépannage
### Les boutons ne fonctionnent pas
Le fichier JavaScript doit exposer les fonctions globalement. Vérifier que le bloc suivant est présent à la fin de `git_pusher.js` :
```javascript
// Exposer les fonctions globalement
window.showDeployerConfigModal = showDeployerConfigModal;
window.closeDeployerConfigModal = closeDeployerConfigModal;
window.saveDeployerConfigFromModal = saveDeployerConfigFromModal;
window.toggleDeployerAuth = toggleDeployerAuth;
// Attacher les événements aux boutons
(function attachButtonEvents() {
function tryAttach() {
var pushBtn = document.getElementById('push-btn');
if (pushBtn) {
pushBtn.addEventListener('click', function(e) {
e.preventDefault();
pushDashboards();
});
}
var buttons = document.querySelectorAll('button.btn');
buttons.forEach(function(btn) {
if (btn.textContent.includes('Reset')) {
btn.addEventListener('click', function(e) {
e.preventDefault();
resetForm(true);
});
}
});
var configBtn = document.querySelector('.deployer-config-btn');
if (configBtn) {
configBtn.addEventListener('click', function(e) {
e.preventDefault();
showDeployerConfigModal();
});
}
if (!pushBtn) setTimeout(tryAttach, 500);
}
if (document.readyState === 'complete') {
setTimeout(tryAttach, 1000);
} else {
window.addEventListener('load', function() {
setTimeout(tryAttach, 1000);
});
}
})();
```
Puis vider le cache :
```bash
rm -rf /opt/splunk/var/run/splunk/appserver/*
/opt/splunk/bin/splunk restart
```
Et dans le navigateur : **Ctrl+Shift+R**
### Erreur 401 Unauthorized (Deployer)
Le token ne correspond pas entre les deux composants.
1. Vérifier le token sur le SH Deployer :
```bash
grep "AUTH_TOKEN" /opt/splunk/etc/apps/deployer_agent/bin/deployer_agent.py
```
2. Configurer le même token dans l'interface (⚙️ Configure)
3. Tester :
```bash
curl -k -H "X-Auth-Token: VOTRE_TOKEN" https://IP_DEPLOYER:9998/status
```
### Erreur "tcsetattr: Inappropriate ioctl for device"
La commande `splunk apply shcluster-bundle` attend une entrée interactive.
Solution : Modifier la fonction `apply_shcluster_bundle` dans `deployer_agent.py` pour utiliser `echo 'y' |` :
```python
shell_cmd = f"echo 'y' | {SPLUNK_BIN} apply shcluster-bundle -target {target_uri} -auth {auth_user}:'{escaped_pass}' -preserve-lookups true"
```
### Erreur CORS
Vider le cache Splunk et navigateur :
```bash
rm -rf /opt/splunk/var/run/splunk/appserver/*
/opt/splunk/bin/splunk restart
```
Puis **Ctrl+Shift+R** dans le navigateur.
### Le SH Deployer ne répond pas
```bash
# Vérifier le statut
./start_deployer_agent.sh status
# Voir les logs
tail -50 /opt/splunk/var/log/splunk/deployer_agent.log
# Redémarrer
./start_deployer_agent.sh restart
```
### Le bundle ne s'applique pas
1. Vérifier que le pull a fonctionné :
```bash
ls -la /opt/splunk/etc/shcluster/apps/
```
2. Vérifier les logs :
```bash
grep -i "bundle\|error" /opt/splunk/var/log/splunk/deployer_agent.log | tail -30
```
3. Tester manuellement :
```bash
echo 'y' | /opt/splunk/bin/splunk apply shcluster-bundle -target https://CAPTAIN_IP:8089 -auth admin:'password' -preserve-lookups true
```
### Vider le cache Splunk
```bash
rm -rf /opt/splunk/var/run/splunk/appserver/*
/opt/splunk/bin/splunk restart
```
---
## 📡 API Reference
### Git Pusher Server (Port 9999)
| Méthode | Endpoint | Description |
|---------|----------|-------------|
| `GET` | `/health` | Health check |
| `GET` | `/license` | Statut de la licence |
| `GET` | `/license/hostname` | Hostname Splunk |
| `GET` | `/deployer/health` | Santé du SH Deployer |
| `GET` | `/deployer/status` | Statut du SH Deployer |
| `GET` | `/deployer/config` | Configuration du SH Deployer |
| `POST` | `/license/upload` | Uploader une licence |
| `POST` | `/push` | Pousser les applications |
### Deployer Agent (Port 9998)
| Méthode | Endpoint | Description |
|---------|----------|-------------|
| `GET` | `/health` | Health check (pas d'auth) |
| `GET` | `/status` | Statut du déploiement |
| `GET` | `/apps` | Liste des apps |
| `GET` | `/history` | Historique des déploiements |
| `POST` | `/pull` | Git pull |
| `POST` | `/deploy` | Apply shcluster-bundle |
| `POST` | `/pull-and-deploy` | Pull + Deploy en une opération |
### Exemple : Push avec déploiement SH Cluster
```bash
curl -k -X POST "https://localhost:9999/push?git_url=https://github.com/user/repo.git&git_branch=main&git_token=TOKEN&commit_message=Update&apps=[{\"id\":\"my_app\"}]&user=admin&deploy_to_shcluster=true"
```
---
## 📝 Changelog
### Version 2.1.0 (Février 2026)
- 🚀 **Nouveau** : Déploiement automatique vers Search Head Cluster
- 🔧 **Nouveau** : Agent Deployer pour le SH Deployer
- ⚙️ **Nouveau** : Interface de configuration du SH Deployer
- 🔐 **Amélioration** : Gestion des caractères spéciaux dans les mots de passe
- 🛠️ **Correction** : Mode non-interactif pour shcluster-bundle
### Version 2.0.0 (Février 2026)
- ✨ Nouveau système de licence par fichier `.lic`
- 🔐 Credentials Splunk chiffrés
- 🔒 Support HTTPS avec certificats SSL
- 🎨 Interface utilisateur modernisée
- 📊 Badge de licence en temps réel
- 🔧 Script de gestion amélioré
- 🛡️ Options pour masquer les boutons d'édition du dashboard
- 📝 Logs détaillés
- 🐛 Correction des problèmes CORS
### Version 1.0.0
- 🚀 Version initiale
- Push d'applications vers Git
- Interface basique
---
## 📞 Support
### Obtenir de l'aide
- 📧 Email : support@gitpusher.com
- 🌐 Site web : https://gitpusher.com
- 📖 Documentation : https://docs.gitpusher.com
### Signaler un bug
Incluez dans votre rapport :
1. Version de Git Pusher
2. Version de Splunk
3. Configuration (HTTP/HTTPS)
4. Architecture (standalone, SH Cluster)
5. Logs Git Pusher (`/opt/splunk/var/log/splunk/git_pusher.log`)
6. Logs Deployer Agent (`/opt/splunk/var/log/splunk/deployer_agent.log`)
7. Erreurs de la console navigateur (F12)
8. Étapes pour reproduire le problème
---
## 📄 Licence
Git Pusher est un logiciel propriétaire. Une licence valide est requise pour son utilisation.
© 2026 Git Pusher - Tous droits réservés
---
<p align="center">
Made with ❤️ for Splunk administrators
</p>