v0.0.10 | README.md 개선
All checks were successful
Build And Test / build-and-push (push) Successful in 3m12s

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-01-17 00:04:15 +09:00
parent 3028d971b5
commit e1b8cb3c9a
2 changed files with 99 additions and 31 deletions

128
README.md
View File

@ -1,41 +1,109 @@
# msa-django-ansible # msa-django-ansible
Ansible Playbook 관리 및 실행을 위한 Django REST API 서비스입니다.
## 기술 스택
| 분류 | 기술 |
|------|------|
| Framework | Django 4.2.14 |
| API | Django REST Framework 3.15.2 |
| Auth | SimpleJWT 5.5.0 (RS256) |
| Automation | Ansible 10.7.0, ansible-core 2.17.7 |
| Database | MySQL (mysqlclient 2.2.7) |
| Docs | drf-yasg 1.21.10 |
| Server | Gunicorn 20.1.0 |
## 주요 기능
- **Playbook 관리**: YAML 형식 Playbook/Inventory 저장
- **작업 실행**: SSH 키 기반 Ansible 실행
- **상태 추적**: pending, running, success, failed, error
- **결과 로깅**: 실행 결과 및 로그 저장
- **JWT 인증**: msa-django-auth와 연동
## API 엔드포인트
| Method | Endpoint | 설명 |
|--------|----------|------|
| GET | `/api/ansible/tasks/` | 작업 목록 조회 |
| POST | `/api/ansible/tasks/` | 새 작업 생성 |
| GET | `/api/ansible/tasks/<id>/` | 작업 상세 조회 |
| PUT/PATCH | `/api/ansible/tasks/<id>/` | 작업 수정 |
| DELETE | `/api/ansible/tasks/<id>/` | 작업 삭제 |
| POST | `/api/ansible/tasks/<id>/run/` | 작업 실행 |
### API 문서
- Swagger UI: `/swagger/`
- ReDoc: `/redoc/`
## 데이터 모델
### AnsibleTask
| 필드 | 타입 | 설명 |
|------|------|------|
| name | CharField | 작업 이름 |
| author_email | CharField | 작성자 이메일 |
| playbook_content | TextField | Playbook YAML |
| inventory_content | TextField | Inventory 내용 |
| status | CharField | 작업 상태 |
| output | TextField | 실행 결과 |
| created_at | DateTimeField | 생성 시간 |
## 환경 변수
```env
# Django
DEBUG=1
SECRET_KEY=your-secret-key
# Database
SQL_ENGINE=django.db.backends.mysql
SQL_HOST=localhost
SQL_USER=user
SQL_PASSWORD=password
SQL_DATABASE=msa-demo
SQL_PORT=3306
# Auth 서버
AUTH_APP_URL=http://192.168.0.202:8000
# JWT
ISTIO_JWT=1
```
## 실행 방법
### 개발 서버
```bash
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txt
python3 manage.py migrate
python3 manage.py runserver 0.0.0.0:8888 python3 manage.py runserver 0.0.0.0:8888
추후 개선필요
auth에 암호화되서 저장된 ssh키를 이쪽에서 호출하고 복호화는 ansible server에서 하도록 해야함...
```bash
python3 -m venv ./venv
``` ```
```bash ### Docker
source ./venv/bin/activate
```
```bash ```bash
# 1. Django 및 DRF docker build -t msa-django-ansible .
pip install django==4.2.14 djangorestframework==3.15.2 docker run -p 8000:8000 --env-file .env.dev msa-django-ansible
# 2. 태그 기능 + CORS
pip install django-taggit django-cors-headers
# 3. JWT 인증
pip install djangorestframework-simplejwt
# 4. Swagger 문서 자동화
pip install drf-yasg
```
## start project
```bash
django-admin startproject ansible_prj .
``` ```
## create app ## 작업 실행 흐름
```bash
python manage.py startapp ansible ```
1. 클라이언트가 POST /api/ansible/tasks/<id>/run/ 요청
2. Auth 서버에서 SSH 키 조회
3. 임시 파일로 playbook, inventory, SSH 키 생성
4. ansible-playbook 명령 실행
5. 결과를 output 필드에 저장
6. 상태를 success/failed/error로 업데이트
``` ```
ansible==10.7.0 ## 연동 서비스
ansible-core==2.17.7
- **msa-django-auth**: JWT 인증, SSH 키 관리

View File

@ -1 +1 @@
v0.0.9_r8 v0.0.10