From 918d65cd49094ebc8ed4ff6a8a2acc4e9a480e75 Mon Sep 17 00:00:00 2001 From: sylvain Date: Sat, 7 Mar 2026 16:45:46 +0000 Subject: [PATCH] =?UTF-8?q?Ajouter=20README=20:=20description,=20skills,?= =?UTF-8?q?=20d=C3=A9ploiement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Sonnet 4.6 --- README.md | 134 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 134 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..6236527 --- /dev/null +++ b/README.md @@ -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: ` | Commande ansible ad-hoc | +| `PLAYBOOK: [options]` | Exécution de playbook | +| `EXEC: ` | Commande shell locale | +| `SEARCH: ` | Recherche DuckDuckGo | +| `READ: ` | Lecture de page web | +| `REMEMBER: \| ` | Mémoire SQLite | +| `RECALL: ` | 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://:11434/api/chat", + "model" : "qwen3:8b", + "xmpp_jid" : "agent2_ansible@xmpp.ovh", + "xmpp_pass" : "", + "admin_jid" : "sylvain@xmpp.ovh", + "mqtt_host" : "", + "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 +```