1. Pourquoi une interface ? #
Industrialiser l'usage d'Ansible en équipe.
Les limites de la ligne de commande #
La CLI est parfaite pour un administrateur, mais en équipe on attend : un contrôle d'accès (qui peut déployer en production ?), un historique des exécutions, la gestion centralisée des credentials, la planification des jobs, des notifications et une API pour l'intégration CI/CD.
| Outil | Licence | Points forts | À savoir |
|---|---|---|---|
| AWX | Open source (Apache 2) | Projet amont de Red Hat AAP : RBAC, workflows, API, execution environments | Déployé via l'opérateur Kubernetes, pas de support officiel |
| Ansible Automation Platform | Commerciale (Red Hat) | Support, Automation Hub, analytics, certifications | Abonnement |
| Semaphore | Open source (MIT) | Très léger, installation en minutes, Ansible/Terraform/scripts | Moins de fonctionnalités entreprise |
| Rundeck | Open source / commerciale | Orchestration générique, planification | Ansible n'est qu'un plugin |
2. Démarrer rapidement avec Semaphore #
Une interface en 5 minutes avec Docker.
Installation avec Docker Compose #
# docker-compose.yml
services:
semaphore:
image: semaphoreui/semaphore:latest
ports: ["3000:3000"]
environment:
SEMAPHORE_DB_DIALECT: bolt
SEMAPHORE_ADMIN: admin
SEMAPHORE_ADMIN_PASSWORD: ChangeMe!
SEMAPHORE_ADMIN_NAME: Administrateur
SEMAPHORE_ADMIN_EMAIL: admin@lab.local
volumes:
- semaphore-data:/var/lib/semaphore
- semaphore-config:/etc/semaphore
volumes: { semaphore-data: {}, semaphore-config: {} }docker compose up -d
# Interface : http://localhost:3000 (admin / ChangeMe!)
# Dans l'interface : Key Store (clé SSH) -> Repository (Git) -> Inventory -> Environment -> Task Template -> Run3. AWX : le standard open source #
Installation et concepts clés.
Installer AWX avec l'opérateur Kubernetes #
# 1. Installer l'opérateur AWX (via kustomize)
cat > kustomization.yaml <<'EOF'
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- github.com/ansible/awx-operator/config/default?ref=2.19.1
images:
- name: quay.io/ansible/awx-operator
newTag: 2.19.1
namespace: awx
EOF
kubectl apply -k .
# 2. Déclarer une instance AWX
cat > awx.yaml <<'EOF'
apiVersion: awx.ansible.com/v1beta1
kind: AWX
metadata:
name: awx-demo
namespace: awx
spec:
service_type: nodeport
EOF
kubectl apply -f awx.yaml
# 3. Suivre le déploiement et récupérer le mot de passe admin
kubectl -n awx get pods -w
kubectl -n awx get secret awx-demo-admin-password -o jsonpath="{.data.password}" | base64 -d; echoLes objets AWX à connaître #
| Objet | Rôle |
|---|---|
| Organization | Périmètre d'isolation (équipes, clients) |
| Credential | Clés SSH, mots de passe, tokens cloud, vault : chiffrés et jamais affichés |
| Project | Dépôt Git contenant les playbooks, synchronisé automatiquement |
| Inventory | Statique ou dynamique (sources AWS, VMware, Git...) |
| Job Template | Playbook + inventaire + credentials + variables : l'unité d'exécution |
| Workflow | Enchaînement conditionnel de job templates (succès, échec, approbation) |
| Schedule / Notification | Planification et alertes (Slack, mail, webhook) |
| Role (RBAC) | Droits : admin, execute, read, use |
4. Automatiser l'automatisation avec l'API et la CLI #
Tout est scriptable.
API REST et awx CLI #
# Lancer un job template depuis un pipeline CI
curl -s -X POST -H "Authorization: Bearer $AWX_TOKEN" -H "Content-Type: application/json" \
-d '{"extra_vars": {"app_version": "1.4.2"}, "limit": "webservers"}' \
https://awx.lab/api/v2/job_templates/42/launch/
# Suivre le job
curl -s -H "Authorization: Bearer $AWX_TOKEN" https://awx.lab/api/v2/jobs/118/ | jq '.status, .elapsed'
# Avec la CLI officielle
pip install awxkit
export TOWER_HOST=https://awx.lab TOWER_OAUTH_TOKEN=$AWX_TOKEN
awx job_templates list --name "Deploy webservers"
awx job_templates launch 42 --monitor --extra_vars '{"app_version":"1.4.2"}'Bonne Pratique : Gérez AWX lui-même en « as code » avec la collection awx.awx ou le provider Terraform : organisations, credentials et templates deviennent reproductibles.