From e1b8cb3c9a9501ebb8d7b2dd0323ec6d041905ca Mon Sep 17 00:00:00 2001 From: icurfer Date: Sat, 17 Jan 2026 00:04:15 +0900 Subject: [PATCH] =?UTF-8?q?v0.0.10=20|=20README.md=20=EA=B0=9C=EC=84=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-By: Claude Opus 4.5 --- README.md | 128 +++++++++++++++++++++++++++++++++++++++++------------- version | 2 +- 2 files changed, 99 insertions(+), 31 deletions(-) diff --git a/README.md b/README.md index 18f8d82..ae4fe9b 100644 --- a/README.md +++ b/README.md @@ -1,41 +1,109 @@ # 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//` | 작업 상세 조회 | +| PUT/PATCH | `/api/ansible/tasks//` | 작업 수정 | +| DELETE | `/api/ansible/tasks//` | 작업 삭제 | +| POST | `/api/ansible/tasks//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 - -추후 개선필요 -auth에 암호화되서 저장된 ssh키를 이쪽에서 호출하고 복호화는 ansible server에서 하도록 해야함... - -```bash -python3 -m venv ./venv ``` -```bash -source ./venv/bin/activate -``` +### Docker ```bash -# 1. Django 및 DRF -pip install django==4.2.14 djangorestframework==3.15.2 - -# 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 . +docker build -t msa-django-ansible . +docker run -p 8000:8000 --env-file .env.dev msa-django-ansible ``` -## create app -```bash -python manage.py startapp ansible +## 작업 실행 흐름 + +``` +1. 클라이언트가 POST /api/ansible/tasks//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 \ No newline at end of file +## 연동 서비스 + +- **msa-django-auth**: JWT 인증, SSH 키 관리 diff --git a/version b/version index 1afaef4..ba00537 100644 --- a/version +++ b/version @@ -1 +1 @@ -v0.0.9_r8 \ No newline at end of file +v0.0.10 \ No newline at end of file