Skip to content

Commit

Permalink
Fix installation services (#135)
Browse files Browse the repository at this point in the history
* feat(compose): comelete compose prompt

* fix(kuber): remove lb

* feat(compose): compelete compose prompt

* nothing

* fix(compose): totally restructre docker compose generator

* fix(compose): directory builder

* fix(compose): compelete compose generation allgorithm

* fix(compose): edit default values for documentation

* feat(compose): add union type input for networks

* fix(routes): add /api to all routes

* fix(installation): fix terraform installation process and model

* fix(installation): create MyBash for scripts

* fix(bash): edit bi/bash

* fix(docker install): fix it

* feat(install): add jenkins and gitlab installation

* Update unit-test.yml

* fix(install): fix jenkins and gitlab
  • Loading branch information
abolfazl8131 authored Dec 10, 2024
1 parent 020aef5 commit 935a2a4
Show file tree
Hide file tree
Showing 33 changed files with 532 additions and 22 deletions.
4 changes: 3 additions & 1 deletion app/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@
from app.routes.helm import *
from app.routes.ansible import *
from app.routes.jcasc import *
from app.routes.docker import *
from app.routes.docker import *
from app.routes.jenkins import *
from app.routes.gitlab import *
19 changes: 19 additions & 0 deletions app/media/Installation_base/Docker/RHEL.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions app/media/Installation_base/Docker/centos.sh
Original file line number Diff line number Diff line change
@@ -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
19 changes: 19 additions & 0 deletions app/media/Installation_base/Docker/fedora.sh
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions app/media/Installation_base/Docker/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions app/media/Installation_base/Gitlab/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# sudo mkdir -p /srv/gitlab
# export GITLAB_HOME=/srv/gitlab

version: '3.6'
services:
gitlab:
image: gitlab/gitlab-ce:<version>-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'
10 changes: 10 additions & 0 deletions app/media/Installation_base/Jenkins/RHEL.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions app/media/Installation_base/Jenkins/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -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
10 changes: 10 additions & 0 deletions app/media/Installation_base/Jenkins/fedora.sh
Original file line number Diff line number Diff line change
@@ -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
13 changes: 13 additions & 0 deletions app/media/Installation_base/Jenkins/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/media/Installation_base/Terraform/amazon_linux.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/media/Installation_base/Terraform/centos.sh
Original file line number Diff line number Diff line change
@@ -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
8 changes: 8 additions & 0 deletions app/media/Installation_base/Terraform/fedora.sh
Original file line number Diff line number Diff line change
@@ -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
15 changes: 15 additions & 0 deletions app/media/Installation_base/Terraform/ubuntu.sh
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions app/media/MyBash/bash.sh
Original file line number Diff line number Diff line change
@@ -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
31 changes: 31 additions & 0 deletions app/media/MyCompose/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# sudo mkdir -p /srv/gitlab
# export GITLAB_HOME=/srv/gitlab

version: '3.6'
services:
gitlab:
image: gitlab/gitlab-ee:<version>-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'
Binary file removed app/media/MyCompose_zip.zip
Binary file not shown.
5 changes: 4 additions & 1 deletion app/models/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,7 @@
from .utils import *
from .ansible_models import *
from .jcasc import *
from .compose_models import *
from .compose_models import *
from .docker_installation_models import *
from .jenkins import *
from .gitlab_models import *
1 change: 0 additions & 1 deletion app/models/compose_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"}}

20 changes: 20 additions & 0 deletions app/models/docker_installation_models.py
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions app/models/gitlab_models.py
Original file line number Diff line number Diff line change
@@ -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
24 changes: 24 additions & 0 deletions app/models/jenkins.py
Original file line number Diff line number Diff line change
@@ -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
22 changes: 11 additions & 11 deletions app/models/terraform_models.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
from pydantic import BaseModel, validator, ValidationError
from typing import List, Optional

from .utils import BasicInput


Expand Down Expand Up @@ -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
Expand Down
Loading

0 comments on commit 935a2a4

Please sign in to comment.