update
This commit is contained in:
45
TERRAFORM.GITLAB.PROJECTS/gitlab.tf
Normal file
45
TERRAFORM.GITLAB.PROJECTS/gitlab.tf
Normal file
@@ -0,0 +1,45 @@
|
||||
provider "gitlab" {
|
||||
token = var.GITLAB_TOKEN
|
||||
}
|
||||
|
||||
resource "gitlab_project" "project" {
|
||||
name = octopusdeploy_tenant.tenant.name
|
||||
allow_merge_on_skipped_pipeline = false
|
||||
only_allow_merge_if_pipeline_succeeds = true
|
||||
remove_source_branch_after_merge = true
|
||||
squash_option = "default_on"
|
||||
ci_config_path = ".gitlab/.gitlab-ci.yml"
|
||||
shared_runners_enabled = false
|
||||
visibility_level = "public"
|
||||
ci_forward_deployment_enabled = true
|
||||
}
|
||||
|
||||
resource "gitlab_branch_protection" "master" {
|
||||
project = gitlab_project.project.id
|
||||
branch = "main"
|
||||
push_access_level = "maintainer"
|
||||
merge_access_level = "developer"
|
||||
allow_force_push = false
|
||||
}
|
||||
|
||||
resource "gitlab_branch_protection" "release" {
|
||||
project = gitlab_project.project.id
|
||||
branch = "release/*"
|
||||
push_access_level = "maintainer"
|
||||
merge_access_level = "developer"
|
||||
allow_force_push = false
|
||||
}
|
||||
|
||||
resource "gitlab_project_runner_enablement" "k3s" {
|
||||
project = gitlab_project.project.id
|
||||
runner_id = octopusdeploy_tenant_common_variable.gitlabrunnerid.value
|
||||
}
|
||||
|
||||
#resource "gitlab_project_variable" "OCTOAPI" {
|
||||
# count = var.OCTOAPI != "" ? 1 : 0
|
||||
# project = gitlab_project.project.id
|
||||
# key = "OCTOAPI"
|
||||
# value = var.OCTOAPI
|
||||
# protected = false
|
||||
# masked = true
|
||||
#}
|
||||
11
TERRAFORM.GITLAB.PROJECTS/import.tf
Normal file
11
TERRAFORM.GITLAB.PROJECTS/import.tf
Normal file
@@ -0,0 +1,11 @@
|
||||
import {
|
||||
to = octopusdeploy_tag.gitlabprojects
|
||||
id = "TagSets-1/Tags-1"
|
||||
}
|
||||
|
||||
import {
|
||||
to = octopusdeploy_tenant.tenant
|
||||
id = var.OCTO_TENANT_ID
|
||||
}
|
||||
|
||||
|
||||
@@ -1,56 +1,14 @@
|
||||
terraform {
|
||||
#backend "http" {}
|
||||
backend "http" {}
|
||||
required_providers {
|
||||
gitlab = {
|
||||
source = "gitlabhq/gitlab"
|
||||
version = "16.2.0"
|
||||
}
|
||||
octopusdeploy = {
|
||||
source = "OctopusDeployLabs/octopusdeploy"
|
||||
version = "0.13.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "gitlab" {
|
||||
token = var.GITLAB_TOKEN
|
||||
}
|
||||
|
||||
resource "gitlab_project" "project" {
|
||||
name = var.GITLAB_PROJECT_NAME
|
||||
allow_merge_on_skipped_pipeline = false
|
||||
only_allow_merge_if_pipeline_succeeds = true
|
||||
remove_source_branch_after_merge = true
|
||||
squash_option = "default_on"
|
||||
ci_config_path = ".gitlab/.gitlab-ci.yml"
|
||||
shared_runners_enabled = false
|
||||
visibility_level = "public"
|
||||
ci_forward_deployment_enabled = true
|
||||
}
|
||||
|
||||
resource "gitlab_branch_protection" "master" {
|
||||
project = gitlab_project.project.id
|
||||
branch = "main"
|
||||
push_access_level = "maintainer"
|
||||
merge_access_level = "developer"
|
||||
allow_force_push = false
|
||||
}
|
||||
|
||||
resource "gitlab_branch_protection" "release" {
|
||||
project = gitlab_project.project.id
|
||||
branch = "release/*"
|
||||
push_access_level = "maintainer"
|
||||
merge_access_level = "developer"
|
||||
allow_force_push = false
|
||||
}
|
||||
|
||||
resource "gitlab_project_runner_enablement" "k3s" {
|
||||
count = var.GITLAB_SHARED_RUNNER_ID != 0 ? 1 : 0
|
||||
project = gitlab_project.project.id
|
||||
runner_id = var.GITLAB_SHARED_RUNNER_ID
|
||||
}
|
||||
|
||||
resource "gitlab_project_variable" "OCTOAPI" {
|
||||
count = var.OCTOAPI != "" ? 1 : 0
|
||||
project = gitlab_project.project.id
|
||||
key = "OCTOAPI"
|
||||
value = var.OCTOAPI
|
||||
protected = false
|
||||
masked = true
|
||||
}
|
||||
|
||||
37
TERRAFORM.GITLAB.PROJECTS/octopus.tf
Normal file
37
TERRAFORM.GITLAB.PROJECTS/octopus.tf
Normal file
@@ -0,0 +1,37 @@
|
||||
provider "octopusdeploy" {
|
||||
address = "https://octopus.internal.durp.info"
|
||||
api_key = var.OCTOAPI
|
||||
}
|
||||
|
||||
resource "octopusdeploy_tenant" "tenant" {
|
||||
name = var.GITLAB_PROJECT_NAME
|
||||
project_environment {
|
||||
environments = [
|
||||
"Environments-1"
|
||||
]
|
||||
project_id = "Projects-1"
|
||||
}
|
||||
tenant_tags = [
|
||||
octopusdeploy_tag.gitlabprojects.canonical_tag_name
|
||||
]
|
||||
}
|
||||
|
||||
resource "octopusdeploy_tag" "gitlabprojects" {
|
||||
name = "Gitlab Project"
|
||||
color = "#333333"
|
||||
tag_set_id = "TagSets-1"
|
||||
}
|
||||
|
||||
resource "octopusdeploy_tenant_common_variable" "gitlabprojectname" {
|
||||
library_variable_set_id = "LibraryVariableSets-2"
|
||||
template_id = "f14ad0ff-d8cf-44a8-bd8d-ff23b0fdb0f4"
|
||||
tenant_id = octopusdeploy_tenant.tenant.id
|
||||
value = var.GITLAB_PROJECT_NAME
|
||||
}
|
||||
|
||||
resource "octopusdeploy_tenant_common_variable" "gitlabrunnerid" {
|
||||
library_variable_set_id = "LibraryVariableSets-2"
|
||||
template_id = "25732879-3567-4d0b-9aad-2769befabf42"
|
||||
tenant_id = octopusdeploy_tenant.tenant.id
|
||||
value = var.GITLAB_SHARED_RUNNER_ID
|
||||
}
|
||||
@@ -16,3 +16,6 @@ variable "OCTOAPI" {
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "OCTO_TENANT_ID" {
|
||||
type = string
|
||||
}
|
||||
|
||||
@@ -1,13 +0,0 @@
|
||||
terraform {
|
||||
required_providers {
|
||||
octopusdeploy = {
|
||||
source = "OctopusDeployLabs/octopusdeploy"
|
||||
version = "0.13.3"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
provider "octopusdeploy" {
|
||||
# Configuration options
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user