Skip to content

Commit

Permalink
feat(nginx_ansible): recreate nginx ansible model
Browse files Browse the repository at this point in the history
  • Loading branch information
abolfazl8131 committed Nov 27, 2024
1 parent 51e8723 commit eaf713a
Show file tree
Hide file tree
Showing 11 changed files with 18 additions and 271 deletions.
17 changes: 0 additions & 17 deletions app/media/MyTerraform/main.tf

This file was deleted.

82 changes: 0 additions & 82 deletions app/media/MyTerraform/modules/efs/main.tf

This file was deleted.

28 changes: 0 additions & 28 deletions app/media/MyTerraform/modules/efs/terraform.tfvars

This file was deleted.

44 changes: 0 additions & 44 deletions app/media/MyTerraform/modules/efs/variables.tf

This file was deleted.

10 changes: 0 additions & 10 deletions app/media/MyTerraform/modules/efs/versions.tf

This file was deleted.

28 changes: 0 additions & 28 deletions app/media/MyTerraform/terraform.tfvars

This file was deleted.

44 changes: 0 additions & 44 deletions app/media/MyTerraform/variables.tf

This file was deleted.

10 changes: 0 additions & 10 deletions app/media/MyTerraform/versions.tf

This file was deleted.

13 changes: 11 additions & 2 deletions app/models/ansible_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
from typing import List, Optional
from pydantic import BaseModel, validator, ValidationError

class AnsibleInstall(BaseModel):


class AnsibleInstallNginx(BaseModel):
os: str = 'ubuntu'
tool: str = 'nginx'
hosts:List[str] = ['www.example.com']
version:str = 'latest'

@validator("os")
def validator_os(cls, value):
if value not in ['ubuntu']:
raise ValueError("Size must be a valid string ending with 'Gi', 'Mi', or 'Ti'.")
return value
8 changes: 4 additions & 4 deletions app/routes/ansible.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
from app.app_instance import app
from app.gpt_services import gpt_service
from app.services import (write_installation,edit_directory_generator,execute_pythonfile)
from app.models import (AnsibleInstall,Output)
from app.models import (AnsibleInstallNginx,Output)
from app.template_generators.ansible.install.main import ansible_install_template
import os

@app.post("/ansible-install/")
async def ansible_install_generation(request:AnsibleInstall) -> Output:
@app.post("/ansible-install/nginx/")
async def ansible_install_generation_nginx(request:AnsibleInstallNginx) -> Output:
if os.environ.get("TEST"):
return Output(output='output')
generated_prompt = ansible_install_template(request)
generated_prompt = ansible_install_template(request,"nginx")
output = gpt_service(generated_prompt)
edit_directory_generator("ansible_generator",output)
execute_pythonfile("MyAnsible","ansible_generator")
Expand Down
5 changes: 3 additions & 2 deletions app/template_generators/ansible/install/main.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
from .docker import ansible_docker_install
from .nginx import ansible_nginx_install
from fastapi import HTTPException
def ansible_install_template(input_):
match input_.tool:

def ansible_install_template(input_, tool:str):
match tool:
case 'nginx':
return ansible_nginx_install(input_)
case 'docker':
Expand Down

0 comments on commit eaf713a

Please sign in to comment.