diff --git a/app/main.py b/app/main.py index ca950b8b..1980475c 100644 --- a/app/main.py +++ b/app/main.py @@ -3,4 +3,6 @@ from app.routes.helm import * from app.routes.ansible import * from app.routes.jcasc import * -from app.routes.docker import * \ No newline at end of file +from app.routes.docker import * +from app.routes.jenkins import * +from app.routes.gitlab import * \ No newline at end of file diff --git a/app/media/Installation_base/Docker/RHEL.sh b/app/media/Installation_base/Docker/RHEL.sh new file mode 100644 index 00000000..6613df87 --- /dev/null +++ b/app/media/Installation_base/Docker/RHEL.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +sudo dnf remove -y \ + docker \ + docker-client \ + docker-client-latest \ + docker-common \ + docker-latest \ + docker-latest-logrotate \ + docker-logrotate \ + docker-engine \ + podman \ + runc + + +sudo dnf -y install dnf-plugins-core +sudo dnf config-manager --add-repo https://download.docker.com/linux/rhel/docker-ce.repo + +sudo dnf install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file diff --git a/app/media/Installation_base/Docker/centos.sh b/app/media/Installation_base/Docker/centos.sh new file mode 100644 index 00000000..b29d7708 --- /dev/null +++ b/app/media/Installation_base/Docker/centos.sh @@ -0,0 +1,16 @@ +#!/bin/bash +sudo dnf remove -y \ + docker \ + docker-client \ + docker-client-latest \ + docker-common \ + docker-latest \ + docker-latest-logrotate \ + docker-logrotate \ + docker-engine + + +sudo dnf -y install dnf-plugins-core +sudo dnf config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo + +sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file diff --git a/app/media/Installation_base/Docker/fedora.sh b/app/media/Installation_base/Docker/fedora.sh new file mode 100644 index 00000000..bbd9cff3 --- /dev/null +++ b/app/media/Installation_base/Docker/fedora.sh @@ -0,0 +1,19 @@ +#!/bin/bash +sudo dnf remove -y \ + docker \ + docker-client \ + docker-client-latest \ + docker-common \ + docker-latest \ + docker-latest-logrotate \ + docker-logrotate \ + docker-selinux \ + docker-engine-selinux \ + docker-engine + + +sudo dnf -y install dnf-plugins-core +sudo dnf-3 config-manager --add-repo https://download.docker.com/linux/fedora/docker-ce.repo + + +sudo dnf -y install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file diff --git a/app/media/Installation_base/Docker/ubuntu.sh b/app/media/Installation_base/Docker/ubuntu.sh new file mode 100644 index 00000000..b223db9f --- /dev/null +++ b/app/media/Installation_base/Docker/ubuntu.sh @@ -0,0 +1,16 @@ +#!/bin/bash +sudo apt-get update -y +sudo apt-get install ca-certificates curl -y +sudo install -m 0755 -d /etc/apt/keyrings +sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc +sudo chmod a+r /etc/apt/keyrings/docker.asc + +# Add the repository to Apt sources: +echo \ + "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ + $(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ + sudo tee /etc/apt/sources.list.d/docker.list > /dev/null +sudo apt-get update -y + + +sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin \ No newline at end of file diff --git a/app/media/Installation_base/Gitlab/docker-compose.yaml b/app/media/Installation_base/Gitlab/docker-compose.yaml new file mode 100644 index 00000000..2c3e366a --- /dev/null +++ b/app/media/Installation_base/Gitlab/docker-compose.yaml @@ -0,0 +1,31 @@ +# sudo mkdir -p /srv/gitlab +# export GITLAB_HOME=/srv/gitlab + +version: '3.6' +services: + gitlab: + image: gitlab/gitlab-ce:-ce.0 + container_name: gitlab + restart: always + hostname: 'gitlab.example.com' + environment: + GITLAB_OMNIBUS_CONFIG: | + # Add any other gitlab.rb configuration here, each on its own line + external_url 'https://gitlab.example.com' + + # you can also use custom HTTP and SSH port. if you you want to do that, follow the below syntax + + # external_url 'http://gitlab.example.com:8929' + # gitlab_rails['gitlab_shell_ssh_port'] = 2424 + + ports: + # - '8929:8929' # Custom HTTP Port + # - '2424:22' # Custom SSH Port + - '80:80' + - '443:443' + - '22:22' + volumes: + - '$GITLAB_HOME/config:/etc/gitlab' + - '$GITLAB_HOME/logs:/var/log/gitlab' + - '$GITLAB_HOME/data:/var/opt/gitlab' + shm_size: '256m' \ No newline at end of file diff --git a/app/media/Installation_base/Jenkins/RHEL.sh b/app/media/Installation_base/Jenkins/RHEL.sh new file mode 100644 index 00000000..5c324160 --- /dev/null +++ b/app/media/Installation_base/Jenkins/RHEL.sh @@ -0,0 +1,10 @@ +#!/bin/bash +sudo wget -O /etc/yum.repos.d/jenkins.repo \ + https://pkg.jenkins.io/redhat-stable/jenkins.repo +sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key +sudo yum upgrade -y +# Add required dependencies for the jenkins package +sudo yum install -y fontconfig java-17-openjdk +sudo yum install -y jenkins +sudo systemctl daemon-reload +sudo systemctl enable --now jenkins \ No newline at end of file diff --git a/app/media/Installation_base/Jenkins/docker-compose.yml b/app/media/Installation_base/Jenkins/docker-compose.yml new file mode 100644 index 00000000..efc50a8b --- /dev/null +++ b/app/media/Installation_base/Jenkins/docker-compose.yml @@ -0,0 +1,15 @@ +version: '3.8' +services: + jenkins: + image: jenkins/jenkins:lts + privileged: true + user: root + ports: + - 8080:8080 + - 50000:50000 + container_name: jenkins + volumes: + - /home/${myname}/jenkins_compose/jenkins_configuration:/var/jenkins_home + - /var/run/docker.sock:/var/run/docker.sock + +# Replace "/home/${myname}/jenkins_compose/jenkins_configuration" with the path you want to use to store your jenkins data \ No newline at end of file diff --git a/app/media/Installation_base/Jenkins/fedora.sh b/app/media/Installation_base/Jenkins/fedora.sh new file mode 100644 index 00000000..aeaa6d7b --- /dev/null +++ b/app/media/Installation_base/Jenkins/fedora.sh @@ -0,0 +1,10 @@ +#!/bin/bash +sudo wget -O /etc/yum.repos.d/jenkins.repo \ + https://pkg.jenkins.io/redhat-stable/jenkins.repo +sudo rpm --import https://pkg.jenkins.io/redhat-stable/jenkins.io-2023.key +sudo dnf upgrade -y +# Add required dependencies for the jenkins package +sudo dnf install -y fontconfig java-17-openjdk +sudo dnf install -y jenkins +sudo systemctl daemon-reload +sudo systemctl enable --now jenkins \ No newline at end of file diff --git a/app/media/Installation_base/Jenkins/ubuntu.sh b/app/media/Installation_base/Jenkins/ubuntu.sh new file mode 100644 index 00000000..fcb3d783 --- /dev/null +++ b/app/media/Installation_base/Jenkins/ubuntu.sh @@ -0,0 +1,13 @@ +#!/bin/bash +sudo apt update -y +sudo apt install -y fontconfig openjdk-17-jre + + +sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ + https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key +echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \ + https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ + /etc/apt/sources.list.d/jenkins.list > /dev/null +sudo apt-get update -y +sudo apt-get install -y jenkins +sudo systemctl enable --now jenkins \ No newline at end of file diff --git a/app/media/Installation_base/Terraform/amazon_linux.sh b/app/media/Installation_base/Terraform/amazon_linux.sh new file mode 100644 index 00000000..fa26a32b --- /dev/null +++ b/app/media/Installation_base/Terraform/amazon_linux.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +sudo yum install -y yum-utils + +sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/AmazonLinux/hashicorp.repo + +sudo yum -y install terraform \ No newline at end of file diff --git a/app/media/Installation_base/Terraform/centos.sh b/app/media/Installation_base/Terraform/centos.sh new file mode 100644 index 00000000..094b3079 --- /dev/null +++ b/app/media/Installation_base/Terraform/centos.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +sudo yum install -y yum-utils + +sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo + +sudo yum -y install terraform \ No newline at end of file diff --git a/app/media/Installation_base/Terraform/fedora.sh b/app/media/Installation_base/Terraform/fedora.sh new file mode 100644 index 00000000..673dbbdf --- /dev/null +++ b/app/media/Installation_base/Terraform/fedora.sh @@ -0,0 +1,8 @@ +#!/bin/bash + + +sudo dnf install -y dnf-plugins-core + +sudo dnf config-manager --add-repo https://rpm.releases.hashicorp.com/fedora/hashicorp.repo + +sudo dnf -y install terraform \ No newline at end of file diff --git a/app/media/Installation_base/Terraform/ubuntu.sh b/app/media/Installation_base/Terraform/ubuntu.sh new file mode 100644 index 00000000..6dc8998a --- /dev/null +++ b/app/media/Installation_base/Terraform/ubuntu.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +sudo apt-get update && sudo apt-get install -y gnupg software-properties-common + +wget -O- https://apt.releases.hashicorp.com/gpg | \ +gpg --dearmor | \ +sudo tee /usr/share/keyrings/hashicorp-archive-keyring.gpg > /dev/null + +echo "deb [signed-by=/usr/share/keyrings/hashicorp-archive-keyring.gpg] \ +https://apt.releases.hashicorp.com $(lsb_release -cs) main" | \ +sudo tee /etc/apt/sources.list.d/hashicorp.list + +sudo apt update + +sudo apt-get install terraform \ No newline at end of file diff --git a/app/media/MyBash/bash.sh b/app/media/MyBash/bash.sh new file mode 100644 index 00000000..5ff50a32 --- /dev/null +++ b/app/media/MyBash/bash.sh @@ -0,0 +1,12 @@ +sudo apt update -y +sudo apt install -y fontconfig openjdk-17-jre + + +sudo wget -O /usr/share/keyrings/jenkins-keyring.asc \ + https://pkg.jenkins.io/debian-stable/jenkins.io-2023.key +echo "deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc]" \ + https://pkg.jenkins.io/debian-stable binary/ | sudo tee \ + /etc/apt/sources.list.d/jenkins.list > /dev/null +sudo apt-get update -y +sudo apt-get install -y jenkins +sudo systemctl enable --now jenkins \ No newline at end of file diff --git a/app/media/MyCompose/docker-compose.yaml b/app/media/MyCompose/docker-compose.yaml index e69de29b..fe15d044 100644 --- a/app/media/MyCompose/docker-compose.yaml +++ b/app/media/MyCompose/docker-compose.yaml @@ -0,0 +1,31 @@ +# sudo mkdir -p /srv/gitlab +# export GITLAB_HOME=/srv/gitlab + +version: '3.6' +services: + gitlab: + image: gitlab/gitlab-ee:-ee.0 + container_name: gitlab + restart: always + hostname: 'gitlab.example.com' + environment: + GITLAB_OMNIBUS_CONFIG: | + # Add any other gitlab.rb configuration here, each on its own line + external_url 'https://gitlab.example.com' + + # you can also use custom HTTP and SSH port. if you you want to do that, follow the below syntax + + # external_url 'http://gitlab.example.com:8929' + # gitlab_rails['gitlab_shell_ssh_port'] = 2424 + + ports: + # - '8929:8929' # Custom HTTP Port + # - '2424:22' # Custom SSH Port + - '80:80' + - '443:443' + - '22:22' + volumes: + - '$GITLAB_HOME/config:/etc/gitlab' + - '$GITLAB_HOME/logs:/var/log/gitlab' + - '$GITLAB_HOME/data:/var/opt/gitlab' + shm_size: '256m' \ No newline at end of file diff --git a/app/media/MyCompose_zip.zip b/app/media/MyCompose_zip.zip deleted file mode 100644 index 66b51797..00000000 Binary files a/app/media/MyCompose_zip.zip and /dev/null differ diff --git a/app/models/__init__.py b/app/models/__init__.py index f206434e..a529a87f 100644 --- a/app/models/__init__.py +++ b/app/models/__init__.py @@ -3,4 +3,7 @@ from .utils import * from .ansible_models import * from .jcasc import * -from .compose_models import * \ No newline at end of file +from .compose_models import * +from .docker_installation_models import * +from .jenkins import * +from .gitlab_models import * \ No newline at end of file diff --git a/app/models/compose_models.py b/app/models/compose_models.py index e48c95d3..059455bc 100644 --- a/app/models/compose_models.py +++ b/app/models/compose_models.py @@ -33,4 +33,3 @@ class DockerCompose(BaseModel): version: str = "3" services: Dict[str, Service] = {"web":Service(), "web2":Service()} networks: Union[Optional[Dict[str, PreCreatedNetwork]],Optional[Dict[str, Network]]] = {"app_network": {"driver":"bridge"}} - diff --git a/app/models/docker_installation_models.py b/app/models/docker_installation_models.py new file mode 100644 index 00000000..f64b9f58 --- /dev/null +++ b/app/models/docker_installation_models.py @@ -0,0 +1,20 @@ +from typing import Dict, List, Optional,Union +from pydantic import BaseModel, model_validator,validator + +class DockerInstallationInput(BaseModel): + os:str = "Ubuntu" + environment:str = "Linux" + + @validator("os") + def validate_os(cls, value): + allowed_os = ['Ubuntu', 'Centos', 'Fedora', 'RHEL'] + if value not in allowed_os: + raise ValueError(f"OS must be one of {allowed_os}.") + return value + + @validator("environment") + def validate_environment(cls, value): + allowed_os = ['Linux'] + if value not in allowed_os: + raise ValueError(f"Environment must be one of {allowed_os}.") + return value \ No newline at end of file diff --git a/app/models/gitlab_models.py b/app/models/gitlab_models.py new file mode 100644 index 00000000..44bbe939 --- /dev/null +++ b/app/models/gitlab_models.py @@ -0,0 +1,17 @@ +from typing import List, Optional +from pydantic import BaseModel, validator, ValidationError + + + +class GitLabInstallation(BaseModel): + + + environment:str = 'Docker' + + + @validator("environment") + def validator_environment(cls, value): + env = ['Docker'] + if value not in env: + raise ValueError(f"your selected Environemnt must be in {env}") + return value \ No newline at end of file diff --git a/app/models/jenkins.py b/app/models/jenkins.py new file mode 100644 index 00000000..e84ca17e --- /dev/null +++ b/app/models/jenkins.py @@ -0,0 +1,24 @@ +from typing import List, Optional +from pydantic import BaseModel, validator, ValidationError + + + +class JenkinsInstallation(BaseModel): + + os: str = 'Ubuntu' + + environment:str = 'Linux' + + @validator("os") + def validator_os(cls, value): + valid_oss = ['Ubuntu','Fedora','RHEL'] + if value not in valid_oss: + raise ValueError(f"your selected OS must be in {valid_oss}") + return value + + @validator("environment") + def validator_environment(cls, value): + env = ['Linux','Docker'] + if value not in env: + raise ValueError(f"your selected Environemnt must be in {env}") + return value \ No newline at end of file diff --git a/app/models/terraform_models.py b/app/models/terraform_models.py index fd615998..42a10f89 100644 --- a/app/models/terraform_models.py +++ b/app/models/terraform_models.py @@ -1,6 +1,5 @@ from pydantic import BaseModel, validator, ValidationError from typing import List, Optional - from .utils import BasicInput @@ -46,22 +45,23 @@ def validate_service(cls, value): return value class IaCInstallationInput(BaseModel): - os:str = "ubuntu" - service:Optional[str] = 'terraform' - + os:str = "Ubuntu" + environment:str = "Linux" + @validator("os") def validate_os(cls, value): - allowed_os = ['ubuntu', 'centos', 'debian'] + allowed_os = ['Ubuntu', 'Centos', 'Fedora', 'Amazon_linux'] if value not in allowed_os: raise ValueError(f"OS must be one of {allowed_os}.") return value - - @validator("service") - def validate_service(cls, value): - allowed_services = ['terraform'] - if value not in allowed_services: - raise ValueError(f"Service must be one of {allowed_services}.") + + @validator("environment") + def validate_environment(cls, value): + allowed_os = ['Linux'] + if value not in allowed_os: + raise ValueError(f"Environment must be one of {allowed_os}.") return value + class IaCTemplateGenerationDocker(BaseModel): docker_image: bool = True diff --git a/app/routes/docker.py b/app/routes/docker.py index 727d9773..913a6ded 100644 --- a/app/routes/docker.py +++ b/app/routes/docker.py @@ -1,8 +1,7 @@ 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 (DockerCompose,Output) +from app.models import (DockerCompose,DockerInstallationInput,Output) from app.template_generators.docker.compose import docker_compose_generator +from app.template_generators.docker.installation import docker_installation_selection import os @app.post("/api/docker-compose/") @@ -13,4 +12,11 @@ async def docker_compose_template(request:DockerCompose) -> Output: docker_compose_generator(request) return Output(output='output') - \ No newline at end of file + + +@app.post("/api/docker/installation") +async def docker_installation(request:DockerInstallationInput) -> Output: + + docker_installation_selection(request) + + return Output(output='output') \ No newline at end of file diff --git a/app/routes/gitlab.py b/app/routes/gitlab.py new file mode 100644 index 00000000..ec8338bf --- /dev/null +++ b/app/routes/gitlab.py @@ -0,0 +1,14 @@ +from app.app_instance import app +from app.models import (GitLabInstallation,Output) +from app.template_generators.gitlab.installation import select_install_gitlab +import os + + + + +@app.post("/api/gitlab/installation") +async def gitlab_installation(request:GitLabInstallation) -> Output: + + select_install_gitlab(request) + + return Output(output='output') \ No newline at end of file diff --git a/app/routes/jenkins.py b/app/routes/jenkins.py new file mode 100644 index 00000000..5f1aa788 --- /dev/null +++ b/app/routes/jenkins.py @@ -0,0 +1,14 @@ +from app.app_instance import app +from app.models import (DockerCompose,JenkinsInstallation,Output) +from app.template_generators.jenkins.installation import select_install_jenkins +import os + + + + +@app.post("/api/jenkins/installation") +async def jenkins_installation(request:JenkinsInstallation) -> Output: + + select_install_jenkins(request) + + return Output(output='output') \ No newline at end of file diff --git a/app/routes/terraform.py b/app/routes/terraform.py index 6efab360..20ebbe03 100644 --- a/app/routes/terraform.py +++ b/app/routes/terraform.py @@ -29,6 +29,7 @@ from app.template_generators.terraform.argocd import (IaC_template_generator_argocd) from app.template_generators.terraform.aws.ELB import (IaC_template_generator_elb) from app.template_generators.terraform.aws.EFS import (IaC_template_generator_efs) +from app.template_generators.terraform.Installation.main import (select_install) import os @app.post("/api/IaC-basic/") @@ -51,10 +52,9 @@ async def IaC_bugfix_generation(request:IaCBugfixInput) -> Output: @app.post("/api/IaC-install/") async def IaC_install_generation(request:IaCInstallationInput) -> Output: if os.environ.get("TEST"): - return Output(output='apt-get install xyz \n apt-get update (covert them to shell file output)') - generated_prompt = IaC_installation_generator(request) - output = gpt_service(generated_prompt) - return Output(output=output) + return Output(output='nothing special') + select_install(request) + return Output(output="pk") @app.post("/api/IaC-template/docker") async def IaC_template_generation_docker(request:IaCTemplateGenerationDocker) -> Output: diff --git a/app/template_generators/docker/__init__.py b/app/template_generators/docker/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/template_generators/docker/installation.py b/app/template_generators/docker/installation.py new file mode 100644 index 00000000..10adcad5 --- /dev/null +++ b/app/template_generators/docker/installation.py @@ -0,0 +1,45 @@ +import os +import shutil + + +def create_MyBash_directory(): + + dir = 'app/media/MyBash' + + + if not os.path.exists(dir): + os.makedirs(dir) + os.path.join(dir, 'bash.sh') + + + +def docker_installation_selection(input): + + create_MyBash_directory() + + match input.os: + + case "Ubuntu": + + source = 'app/media/Installation_base/Docker/ubuntu.sh' + dest = 'app/media/MyBash/bash.sh' + + shutil.copyfile(source, dest) + + + case "Fedora": + source = 'app/media/Installation_base/Docker/fedora.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "Centos": + source = 'app/media/Installation_base/Docker/centos.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "RHEL": + source = 'app/media/Installation_base/Docker/RHEL.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + case _: + raise ValueError() \ No newline at end of file diff --git a/app/template_generators/gitlab/installation.py b/app/template_generators/gitlab/installation.py new file mode 100644 index 00000000..a50c333e --- /dev/null +++ b/app/template_generators/gitlab/installation.py @@ -0,0 +1,35 @@ +import os +import shutil + + +def create_directory(folder:str,filename:str): + + dir = f"app/media/{folder}" + + + if not os.path.exists(dir): + os.makedirs(dir) + os.path.join(dir, filename) + + +def select_install_gitlab(input): + + create_directory("MyCompose","docker-compose.yaml") + + + match input.environment: + + case "Docker": + source = 'app/media/Installation_base/Gitlab/docker-compose.yaml' + dest = 'app/media/MyCompose/docker-compose.yaml' + shutil.copyfile(source, dest) + + + case _: + raise ValueError() + + + + + + \ No newline at end of file diff --git a/app/template_generators/jenkins/installation.py b/app/template_generators/jenkins/installation.py new file mode 100644 index 00000000..4177124e --- /dev/null +++ b/app/template_generators/jenkins/installation.py @@ -0,0 +1,55 @@ +import os +import shutil + + +def create_directory(folder:str,filename:str): + + dir = f"app/media/{folder}" + + + if not os.path.exists(dir): + os.makedirs(dir) + os.path.join(dir, filename) + + + +def select_install_jenkins(input): + + create_directory("MyBash",'bash.sh') + create_directory("MyCompose",'docker-compose.yaml') + + if input.environment == 'Docker': + + source = 'app/media/Installation_base/Jenkins/docker-compose.yml' + dest = 'app/media/MyCompose/docker-compose.yaml' + shutil.copyfile(source, dest) + + else: + + match input.os: + + + case "Ubuntu": + source = 'app/media/Installation_base/Jenkins/ubuntu.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "Fedora": + source = 'app/media/Installation_base/Jenkins/fedora.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + + case "RHEL": + source = 'app/media/Installation_base/Jenkins/RHEL.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case _: + raise ValueError() + + + + + + \ No newline at end of file diff --git a/app/template_generators/terraform/Installation/__init__.py b/app/template_generators/terraform/Installation/__init__.py new file mode 100644 index 00000000..e69de29b diff --git a/app/template_generators/terraform/Installation/main.py b/app/template_generators/terraform/Installation/main.py new file mode 100644 index 00000000..c4c479e4 --- /dev/null +++ b/app/template_generators/terraform/Installation/main.py @@ -0,0 +1,45 @@ +import os +import shutil + + +def create_directory(folder:str,filename:str): + + dir = f"app/media/{folder}" + + + if not os.path.exists(dir): + os.makedirs(dir) + os.path.join(dir, filename) + + + +def select_install(input): + create_directory("MyBash","bash.sh") + + match input.os: + + + case "Ubuntu": + source = 'app/media/Installation_base/Terraform/ubuntu.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "Fedora": + source = 'app/media/Installation_base/Terraform/fedora.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "Centos": + source = 'app/media/Installation_base/Terraform/centos.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + + case "Amazon_linux": + source = 'app/media/Installation_base/Terraform/amazon_linux.sh' + dest = 'app/media/MyBash/bash.sh' + shutil.copyfile(source, dest) + case _: + raise ValueError() + + + \ No newline at end of file