Skip to content

Commit

Permalink
Merge pull request devopshobbies#92 from abolfazl8131/master
Browse files Browse the repository at this point in the history
feat(argocd): fix argocd models
  • Loading branch information
mohammadll authored Nov 24, 2024
2 parents 37e6490 + c7e5d9d commit 2d770a3
Show file tree
Hide file tree
Showing 17 changed files with 270 additions and 469 deletions.
353 changes: 124 additions & 229 deletions app/directory_generators/terraform_generator.py

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion app/media/MyTerraform/.terraform/modules/modules.json

This file was deleted.

29 changes: 12 additions & 17 deletions app/media/MyTerraform/main.tf
Original file line number Diff line number Diff line change
@@ -1,22 +1,17 @@

provider "aws" {
region = "us-east-1"
provider "argocd" {
server_addr = var.argocd_instance_info["server_addr"]
username = var.argocd_instance_info["username"]
password = var.argocd_instance_info["password"]
insecure = var.argocd_instance_info["insecure"]
}

module "ec2" {
source = "./modules/ec2"
module "argocd" {
source = "./modules/argocd"

key_pair_create = var.key_pair_create
key_pair_name = var.key_pair_name

security_group_create = var.security_group_create
security_group_name = var.security_group_name
security_group_ingress_rules = var.security_group_ingress_rules
security_group_egress_rule = var.security_group_egress_rule

instance_create = var.instance_create
instance_type = var.instance_type

ami_from_instance_create = var.ami_from_instance_create
ami_name = var.ami_name
repository_create = var.repository_create
argocd_repository_info = var.argocd_repository_info
application_create = var.application_create
argocd_application = var.argocd_application
argocd_sync_options = var.argocd_sync_options
}
39 changes: 39 additions & 0 deletions app/media/MyTerraform/modules/argocd/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

resource "argocd_repository" "repository" {
count = var.repository_create ? 1 : 0
repo = var.argocd_repository_info["repo"]
username = var.argocd_repository_info["username"]
password = var.argocd_repository_info["password"]
}

resource "argocd_application" "application" {
count = var.application_create ? 1 : 0
depends_on = [argocd_repository.repository]

metadata {
name = var.argocd_application["name"]
namespace = "argocd"
labels = {
using_sync_policy_options = "true"
}
}

spec {
destination {
server = var.argocd_application["destination_server"]
namespace = var.argocd_application["destination_namespace"]
}
source {
repo_url = var.argocd_application["source_repo_url"]
path = var.argocd_application["source_path"]
target_revision = var.argocd_application["source_target_revision"]
}
sync_policy {
automated {
prune = true
self_heal = true
}
sync_options = var.argocd_sync_options
}
}
}
19 changes: 19 additions & 0 deletions app/media/MyTerraform/modules/argocd/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@

repository_create = true
argocd_repository_info = {
repo = "https://YOUR_REPO.git"
username = "USERNAME"
password = "CHANGE_ME_WITH_TOKEN"
}

application_create = true
argocd_application = {
name = "APPLICATION_NAME"
destination_server = "https://kubernetes.default.svc"
destination_namespace = "DESTINATION_NAMESPACE"
source_repo_url = "https://YOUR_REPO.git"
source_path = "SOURCE_PATH"
source_target_revision = "SOURCE_TARGET_REVISION"
}

argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
20 changes: 20 additions & 0 deletions app/media/MyTerraform/modules/argocd/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@

variable "repository_create" {
type = bool
}

variable "argocd_repository_info" {
type = map(string)
}

variable "application_create" {
type = bool
}

variable "argocd_application" {
type = map(string)
}

variable "argocd_sync_options" {
type = list(string)
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ terraform {
required_version = ">= 1.0"

required_providers {
aws = {
source = "hashicorp/aws"
version = ">= 5.20"
argocd = {
source = "oboukili/argocd"
version = ">= 6.0.2"
}
}
}
63 changes: 0 additions & 63 deletions app/media/MyTerraform/modules/ec2/main.tf

This file was deleted.

Empty file.
34 changes: 0 additions & 34 deletions app/media/MyTerraform/modules/ec2/terraform.tfvars

This file was deleted.

51 changes: 0 additions & 51 deletions app/media/MyTerraform/modules/ec2/variables.tf

This file was deleted.

50 changes: 21 additions & 29 deletions app/media/MyTerraform/terraform.tfvars
Original file line number Diff line number Diff line change
@@ -1,34 +1,26 @@

key_pair_create = true
key_pair_name = "ec2"

security_group_create = true
security_group_name = "my_rules"
security_group_ingress_rules = {
ssh_rule = {
description = "SSH Ingress"
from_port = 22
to_port = 22
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
},
http_rule = {
description = "HTTP Ingress"
from_port = 80
to_port = 80
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
argocd_instance_info = {
server_addr = "ARGOCD_DOMAIN"
username = "admin"
password = "ARGOCD_ADMIN_PASS"
insecure = true
}
security_group_egress_rule = {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]

repository_create = true
argocd_repository_info = {
repo = "https://YOUR_REPO.git"
username = "USERNAME"
password = "CHANGE_ME_WITH_TOKEN"
}

instance_create = false
instance_type = "t2.micro"
application_create = true
argocd_application = {
name = "APPLICATION_NAME"
destination_server = "https://kubernetes.default.svc"
destination_namespace = "DESTINATION_NAMESPACE"
source_repo_url = "https://YOUR_REPO.git"
source_path = "SOURCE_PATH"
source_target_revision = "SOURCE_TARGET_REVISION"
}

ami_from_instance_create = true
ami_name = "my-own-ami"
argocd_sync_options = ["CreateNamespace=true", "ApplyOutOfSyncOnly=true", "FailOnSharedResource=true"]
Loading

0 comments on commit 2d770a3

Please sign in to comment.