Compare commits
47 Commits
release/1.
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6ff48c3a35 | ||
| 43371eaf10 | |||
| f3ffff7d94 | |||
| 554066cd4b | |||
| dc049508b9 | |||
| b3f21b6113 | |||
| 9c52840bc5 | |||
|
|
1f17866b90 | ||
|
|
3f9116f88f | ||
| 39a61204f9 | |||
| 523ccc4a83 | |||
| 9995e280f4 | |||
| 652a8dcc18 | |||
| 53ad5f6f45 | |||
| f04837f48f | |||
| 910aa7684b | |||
| d132cbe41e | |||
| 2c30d55c58 | |||
| 3f0986ab46 | |||
| 482d338b9e | |||
| c22d2d1562 | |||
| 8309dc87c6 | |||
| c46b614d86 | |||
| 74ee55599f | |||
| d23e3ed9cd | |||
| 62090b47e1 | |||
| 94df41bd5f | |||
| 94d9c735dc | |||
| fe210a909f | |||
| 7395e64da0 | |||
| e6a6968e35 | |||
| 25d045aed4 | |||
| 73cf0bd314 | |||
| 99996e3a05 | |||
| 6a4c19b314 | |||
| 1b7a0fb045 | |||
| bb8774a842 | |||
| e365c38695 | |||
| cc6aa74cbc | |||
| 5562bd3173 | |||
| 4fc4e646e7 | |||
| a229cc96b2 | |||
| 22ab70e34a | |||
| 94964dea8c | |||
| 48ea006ca7 | |||
|
|
048c69938a | ||
| c1d2bb7de2 |
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1,3 @@
|
|||||||
.terraform*
|
.terraform*
|
||||||
.env
|
.env
|
||||||
|
*.tfstate*
|
||||||
|
|||||||
@@ -1,5 +1,8 @@
|
|||||||
include:
|
include:
|
||||||
- project: 'developerdurp/yml'
|
- project: 'developerdurp/yml'
|
||||||
ref: 'main'
|
ref: 'main'
|
||||||
file: 'pipelines/gitlab_generic_packages.yml'
|
file:
|
||||||
- local: .variables.yml
|
- 'pipeline.yml'
|
||||||
|
#- 'pipelines/gitlab_generic_packages.yml'
|
||||||
|
#- 'pipelines/docker-build-generic.yml'
|
||||||
|
- local: .variables.yml
|
||||||
|
|||||||
49
.octopus/deployment_process.ocl
Normal file
49
.octopus/deployment_process.ocl
Normal file
@@ -0,0 +1,49 @@
|
|||||||
|
step "plan-to-apply-a-terraform-template" {
|
||||||
|
name = "Terraform Plan"
|
||||||
|
|
||||||
|
action "terraform-plan" {
|
||||||
|
is_required = true
|
||||||
|
properties = {
|
||||||
|
Octopus.Action.RunOnServer = "true"
|
||||||
|
Octopus.Action.Template.Id = "ActionTemplates-1"
|
||||||
|
Octopus.Action.Template.Version = "3"
|
||||||
|
}
|
||||||
|
worker_pool_variable = ""
|
||||||
|
|
||||||
|
container {
|
||||||
|
feed = "nexus"
|
||||||
|
image = "#{TF_Container}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
step "approve-plan" {
|
||||||
|
name = "Approve Plan"
|
||||||
|
|
||||||
|
action {
|
||||||
|
is_required = true
|
||||||
|
properties = {
|
||||||
|
Octopus.Action.RunOnServer = "false"
|
||||||
|
Octopus.Action.Template.Id = "ActionTemplates-3"
|
||||||
|
Octopus.Action.Template.Version = "0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
step "terraform-apply" {
|
||||||
|
name = "Terraform Apply"
|
||||||
|
|
||||||
|
action {
|
||||||
|
properties = {
|
||||||
|
Octopus.Action.RunOnServer = "true"
|
||||||
|
Octopus.Action.Template.Id = "ActionTemplates-2"
|
||||||
|
Octopus.Action.Template.Version = "1"
|
||||||
|
}
|
||||||
|
worker_pool_variable = ""
|
||||||
|
|
||||||
|
container {
|
||||||
|
feed = "nexus"
|
||||||
|
image = "#{TF_Container}"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
9
.octopus/deployment_settings.ocl
Normal file
9
.octopus/deployment_settings.ocl
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
default_guided_failure_mode = "On"
|
||||||
|
|
||||||
|
connectivity_policy {
|
||||||
|
allow_deployments_to_no_targets = true
|
||||||
|
}
|
||||||
|
|
||||||
|
versioning_strategy {
|
||||||
|
template = "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.NextPatch}"
|
||||||
|
}
|
||||||
1
.octopus/schema_version.ocl
Normal file
1
.octopus/schema_version.ocl
Normal file
@@ -0,0 +1 @@
|
|||||||
|
version = 6
|
||||||
30
.octopus/variables.ocl
Normal file
30
.octopus/variables.ocl
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
variable "TF_PACKAGE" {
|
||||||
|
value "TERRAFORM.GITLAB.PROJECTS" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "TF_CONTAINER" {
|
||||||
|
value "developerdurp/octopus-build-container:22.4.0" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "GITLAB_PROJECT_ID" {
|
||||||
|
value "52389386" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "RUNSPACE_GITLAB_PROJECT_IMPORT" {
|
||||||
|
value {
|
||||||
|
process = ["runbook/import-project"]
|
||||||
|
|
||||||
|
prompt {
|
||||||
|
description = ""
|
||||||
|
label = ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "TF_INIT" {
|
||||||
|
value "-backend-config=\"address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/#{Octopus.Deployment.Tenant.Id}\" -backend-config=\"lock_address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/#{Octopus.Deployment.Tenant.Id}/lock\" -backend-config=\"unlock_address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/#{Octopus.Deployment.Tenant.Id}/lock\" -backend-config=\"username=developerdurp\" -backend-config=\"password=#{GITLAB_TOKEN}\" -backend-config=\"lock_method=POST\" -backend-config=\"unlock_method=DELETE\" -backend-config=\"retry_wait_min=5\"" {}
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "OCTO_TENANT_ID" {
|
||||||
|
value "#{Octopus.Deployment.Tenant.Id}" {}
|
||||||
|
}
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
variables:
|
variables:
|
||||||
PROJECT_NAME: TERRAFORM.GITLAB.PROJECTS
|
PIPELINE: 'gitlab'
|
||||||
OCTO_PROJECT_NAME: "Gitlab Projects"
|
PROJECT_NAME: "TERRAFORM.GITLAB.PROJECTS"
|
||||||
|
OCTO_PROJECT_NAME: "Gitlab Projects"
|
||||||
|
|||||||
13
Dockerfile
13
Dockerfile
@@ -1,13 +0,0 @@
|
|||||||
FROM ubuntu:22.04
|
|
||||||
|
|
||||||
RUN apt-get update && \
|
|
||||||
apt-get install -y --no-install-recommends \
|
|
||||||
curl \
|
|
||||||
unzip \
|
|
||||||
apt-transport-https \
|
|
||||||
software-properties-common && \
|
|
||||||
apt-get clean && \
|
|
||||||
rm -rf /var/lib/apt/lists/*
|
|
||||||
|
|
||||||
RUN curl https://releases.hashicorp.com/terraform/1.6.4/terraform_1.6.4_linux_amd64.zip -o tf.zip
|
|
||||||
RUN unzip -d /usr/local/bin/ tf.zip && rm tf.zip
|
|
||||||
46
TERRAFORM.GITLAB.PROJECTS/gitlab.tf
Normal file
46
TERRAFORM.GITLAB.PROJECTS/gitlab.tf
Normal file
@@ -0,0 +1,46 @@
|
|||||||
|
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 = var.GITLAB_SHARED_RUNNER_ID
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
resource "gitlab_project_variable" "OCTOAPI" {
|
||||||
|
count = var.Enable_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
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -5,40 +5,10 @@ terraform {
|
|||||||
source = "gitlabhq/gitlab"
|
source = "gitlabhq/gitlab"
|
||||||
version = "16.2.0"
|
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
|
|
||||||
}
|
|
||||||
|
|
||||||
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 = var.GITLAB_SHARED_RUNNER_ID
|
|
||||||
}
|
|
||||||
|
|||||||
34
TERRAFORM.GITLAB.PROJECTS/octopus.tf
Normal file
34
TERRAFORM.GITLAB.PROJECTS/octopus.tf
Normal file
@@ -0,0 +1,34 @@
|
|||||||
|
provider "octopusdeploy" {
|
||||||
|
address = "https://octopus.internal.durp.info"
|
||||||
|
api_key = var.OCTOAPI
|
||||||
|
}
|
||||||
|
|
||||||
|
resource "octopusdeploy_tenant" "tenant" {
|
||||||
|
name = var.GITLAB_PROJECT_NAME
|
||||||
|
project_environment {
|
||||||
|
environments = var.Development ? [
|
||||||
|
"Environments-1",
|
||||||
|
"Environments-2"
|
||||||
|
] : [
|
||||||
|
"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 = octopusdeploy_tenant.tenant.name
|
||||||
|
}
|
||||||
|
|
||||||
@@ -2,14 +2,30 @@ variable "GITLAB_TOKEN" {
|
|||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "GITLAB_PROJECT_ID" {
|
|
||||||
type = number
|
|
||||||
}
|
|
||||||
|
|
||||||
variable "GITLAB_PROJECT_NAME" {
|
variable "GITLAB_PROJECT_NAME" {
|
||||||
type = string
|
type = string
|
||||||
}
|
}
|
||||||
|
|
||||||
variable "GITLAB_SHARED_RUNNER_ID" {
|
variable "GITLAB_SHARED_RUNNER_ID" {
|
||||||
type = number
|
type = number
|
||||||
|
default = 0
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "Enable_OCTOAPI" {
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "OCTOAPI" {
|
||||||
|
type = string
|
||||||
|
default = ""
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "OCTO_TENANT_ID" {
|
||||||
|
type = string
|
||||||
|
}
|
||||||
|
|
||||||
|
variable "Development" {
|
||||||
|
type = bool
|
||||||
|
default = false
|
||||||
}
|
}
|
||||||
|
|||||||
7
TERRAFORM.GITLAB.PROJECTS/variables.tfvars
Normal file
7
TERRAFORM.GITLAB.PROJECTS/variables.tfvars
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
GITLAB_TOKEN="#{GITLAB_TOKEN}"
|
||||||
|
GITLAB_PROJECT_NAME="#{GITLAB_PROJECT_NAME}"
|
||||||
|
GITLAB_SHARED_RUNNER_ID="#{GITLAB_SHARED_RUNNER_ID}"
|
||||||
|
OCTOAPI="#{OCTOAPI}"
|
||||||
|
Enable_OCTOAPI="#{Enable_OCTOAPI}"
|
||||||
|
OCTO_TENANT_ID="#{OCTO_TENANT_ID}"
|
||||||
|
Development="#{Development}"
|
||||||
Reference in New Issue
Block a user