Ajouter README : description, skills, déploiement
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,134 @@
|
||||
# Agent2_Ansible — Automatisation Ansible
|
||||
|
||||
Agent spécialisé dans l'automatisation d'infrastructure via Ansible. Exécute des playbooks et commandes ad-hoc sur les machines du réseau local.
|
||||
|
||||
## Rôle
|
||||
|
||||
- Exécution de playbooks Ansible sur les hôtes du réseau local
|
||||
- Commandes ad-hoc Ansible (ping, shell, apt, service, copy...)
|
||||
- Gestion de l'inventaire et collecte de facts
|
||||
- Déploiement de configurations sur plusieurs machines simultanément
|
||||
- Rapporte les résultats à agent1 via MQTT
|
||||
|
||||
## Skills disponibles
|
||||
|
||||
| Trigger | Description |
|
||||
|---|---|
|
||||
| `ANSIBLE: <args>` | Commande ansible ad-hoc |
|
||||
| `PLAYBOOK: <fichier.yml> [options]` | Exécution de playbook |
|
||||
| `EXEC: <commande>` | Commande shell locale |
|
||||
| `SEARCH: <requête>` | Recherche DuckDuckGo |
|
||||
| `READ: <url>` | Lecture de page web |
|
||||
| `REMEMBER: <clé> \| <valeur>` | Mémoire SQLite |
|
||||
| `RECALL: <clé>` | Récupération mémoire |
|
||||
|
||||
## Exemples de tâches
|
||||
|
||||
```
|
||||
ANSIBLE: all -m ping
|
||||
ANSIBLE: all -m shell -a "uptime"
|
||||
ANSIBLE: webservers -m apt -a "name=nginx state=present" --become
|
||||
ANSIBLE: all -m gather_facts
|
||||
PLAYBOOK: site.yml
|
||||
PLAYBOOK: deploy.yml --limit webservers --tags packages
|
||||
PLAYBOOK: update.yml --check
|
||||
```
|
||||
|
||||
## Inventaire
|
||||
|
||||
Editer `/opt/agent2_ansible/ansible/inventory/hosts` pour déclarer les machines :
|
||||
|
||||
```ini
|
||||
[servers]
|
||||
srv1 ansible_host=192.168.7.10 ansible_user=root
|
||||
srv2 ansible_host=192.168.7.11 ansible_user=debian
|
||||
|
||||
[workstations]
|
||||
pc1 ansible_host=192.168.7.50 ansible_user=sylvain
|
||||
|
||||
[all:vars]
|
||||
ansible_python_interpreter=/usr/bin/python3
|
||||
```
|
||||
|
||||
## Playbooks
|
||||
|
||||
Placer les playbooks dans `/opt/agent2_ansible/ansible/playbooks/`.
|
||||
|
||||
## Déploiement via agent2_deploy (recommandé)
|
||||
|
||||
```
|
||||
# Via XMPP avec sylvain@xmpp.ovh, contacter agent2_deploy :
|
||||
!deploy
|
||||
# Choisir agent2_ansible, puis suivre le guide
|
||||
```
|
||||
|
||||
## Déploiement manuel
|
||||
|
||||
```bash
|
||||
# Prérequis
|
||||
apt-get install -y python3 python3-pip python3-venv git ansible
|
||||
|
||||
# Cloner et installer
|
||||
git clone https://git.piaf.im/sylvain/agent2_ansible.git /opt/agent2_ansible
|
||||
cd /opt/agent2_ansible
|
||||
python3 -m venv venv
|
||||
venv/bin/pip install slixmpp paho-mqtt requests ddgs beautifulsoup4 chromadb
|
||||
|
||||
# Configurer
|
||||
nano config/config.json
|
||||
nano ansible/inventory/hosts
|
||||
|
||||
# Service systemd
|
||||
cat > /etc/systemd/system/agent2_ansible.service << 'EOF'
|
||||
[Unit]
|
||||
Description=Agent2 Ansible
|
||||
After=network.target mosquitto.service
|
||||
Wants=mosquitto.service
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
WorkingDirectory=/opt/agent2_ansible
|
||||
ExecStart=/usr/bin/python3 /opt/agent2_ansible/agent2_ansible.py
|
||||
Restart=always
|
||||
RestartSec=5
|
||||
StandardOutput=journal
|
||||
StandardError=journal
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
systemctl daemon-reload
|
||||
systemctl enable agent2_ansible
|
||||
systemctl start agent2_ansible
|
||||
```
|
||||
|
||||
## Déploiement depuis le dépôt git (sur la machine cible)
|
||||
|
||||
```bash
|
||||
git clone https://git.piaf.im/sylvain/agent2_deploy.git /tmp/agent2_deploy
|
||||
python3 /tmp/agent2_deploy/deploy.py --local agent2_ansible
|
||||
```
|
||||
|
||||
## Configuration (`config/config.json`)
|
||||
|
||||
```json
|
||||
{
|
||||
"ollama_url" : "http://<ip_ollama>:11434/api/chat",
|
||||
"model" : "qwen3:8b",
|
||||
"xmpp_jid" : "agent2_ansible@xmpp.ovh",
|
||||
"xmpp_pass" : "<mot_de_passe>",
|
||||
"admin_jid" : "sylvain@xmpp.ovh",
|
||||
"mqtt_host" : "<ip_broker_mqtt>",
|
||||
"mqtt_port" : 1883,
|
||||
"mqtt_client_id" : "agent2_ansible",
|
||||
"mqtt_inbox" : "agents/agent2_ansible/inbox",
|
||||
"mqtt_outbox" : "agents/agent1/inbox"
|
||||
}
|
||||
```
|
||||
|
||||
## Logs
|
||||
|
||||
```bash
|
||||
journalctl -u agent2_ansible -f
|
||||
```
|
||||
Reference in New Issue
Block a user