39 Commits

Author SHA1 Message Date
Octopus Deploy
6ff48c3a35 Update step template version 2023-12-19 21:12:28 -06:00
43371eaf10 update 2023-12-19 20:51:08 -06:00
f3ffff7d94 [skip ci] 2023-12-19 20:49:45 -06:00
554066cd4b update 2023-12-19 20:43:45 -06:00
dc049508b9 update 2023-12-19 08:19:22 -06:00
b3f21b6113 update 2023-12-19 08:14:11 -06:00
9c52840bc5 Update deployment process 2023-12-17 08:12:08 -06:00
Octopus Deploy
1f17866b90 Update step template version 2023-12-17 08:11:20 -06:00
Octopus Deploy
3f9116f88f Update step template version 2023-12-17 08:09:20 -06:00
39a61204f9 [skip cip] 2023-12-17 08:06:53 -06:00
523ccc4a83 [skip ci] 2023-12-15 19:53:37 -06:00
9995e280f4 Update deployment process 2023-12-14 20:03:22 -06:00
652a8dcc18 Update deployment process 2023-12-14 19:57:55 -06:00
53ad5f6f45 Update deployment process 2023-12-14 19:53:20 -06:00
f04837f48f Update deployment process 2023-12-14 19:47:03 -06:00
910aa7684b Update deployment process 2023-12-14 19:35:46 -06:00
d132cbe41e [skip ci] 2023-12-14 19:35:17 -06:00
2c30d55c58 Update file variables.tfvars 2023-12-13 15:00:01 +00:00
3f0986ab46 Update deployment process 2023-12-13 08:50:32 -06:00
482d338b9e Update variables 2023-12-13 08:45:59 -06:00
c22d2d1562 Update deployment process 2023-12-13 07:12:53 -06:00
8309dc87c6 Update file variables.tfvars 2023-12-13 13:10:26 +00:00
c46b614d86 [skip ci] 2023-11-26 12:14:02 -06:00
74ee55599f update 2023-11-26 11:54:07 -06:00
d23e3ed9cd [skip ci] 2023-11-26 11:49:41 -06:00
62090b47e1 Update deployment process 2023-11-26 10:54:44 -06:00
94df41bd5f [skip ci] 2023-11-26 10:52:17 -06:00
94d9c735dc update 2023-11-26 10:47:24 -06:00
fe210a909f update 2023-11-26 10:45:01 -06:00
7395e64da0 [skip ci] 2023-11-26 10:44:04 -06:00
e6a6968e35 [skip ci] 2023-11-26 10:42:42 -06:00
25d045aed4 update 2023-11-26 06:31:47 -06:00
73cf0bd314 updaate 2023-11-25 21:05:59 -06:00
99996e3a05 update 2023-11-25 21:00:57 -06:00
6a4c19b314 update 2023-11-25 19:58:22 -06:00
1b7a0fb045 [skip ci] 2023-11-25 19:58:06 -06:00
bb8774a842 update pipeline 2023-11-25 05:00:28 -06:00
e365c38695 [skip ci] 2023-11-24 08:58:37 -06:00
cc6aa74cbc Update variables 2023-11-23 16:04:11 -06:00
13 changed files with 157 additions and 128 deletions

1
.gitignore vendored
View File

@@ -1,2 +1,3 @@
.terraform*
.env
*.tfstate*

View File

@@ -2,6 +2,7 @@ include:
- project: 'developerdurp/yml'
ref: 'main'
file:
- 'pipelines/gitlab_generic_packages.yml'
- 'pipeline.yml'
#- 'pipelines/gitlab_generic_packages.yml'
#- 'pipelines/docker-build-generic.yml'
- local: .variables.yml

View File

@@ -2,26 +2,11 @@ step "plan-to-apply-a-terraform-template" {
name = "Terraform Plan"
action "terraform-plan" {
action_type = "Octopus.TerraformPlan"
environments = ["development"]
is_required = true
properties = {
Octopus.Action.GoogleCloud.ImpersonateServiceAccount = "False"
Octopus.Action.GoogleCloud.UseVMServiceAccount = "True"
Octopus.Action.Package.DownloadOnTentacle = "False"
Octopus.Action.Package.FeedId = "nexus-nuget"
Octopus.Action.Package.PackageId = "#{TF_PACKAGE}"
Octopus.Action.RunOnServer = "true"
Octopus.Action.Script.ScriptSource = "Package"
Octopus.Action.Terraform.AdditionalInitParams = "#{TF_INIT}"
Octopus.Action.Terraform.AllowPluginDownloads = "True"
Octopus.Action.Terraform.AzureAccount = "False"
Octopus.Action.Terraform.EnvVariables = "{\"TF_VAR_GITLAB_PROJECT_ID\":\"#{GITLAB_PROJECT_ID}\",\"TF_VAR_GITLAB_PROJECT_NAME\":\"#{GITLAB_PROJECT_NAME}\",\"TF_VAR_GITLAB_SHARED_RUNNER_ID\":\"#{GITLAB_SHARED_RUNNER_ID}\",\"TF_VAR_GITLAB_TOKEN\":\"#{GITLAB_TOKEN}\",\"TF_VAR_OCTOAPI\":\"#{OCTOAPI}\"}"
Octopus.Action.Terraform.GoogleCloudAccount = "False"
Octopus.Action.Terraform.ManagedAccount = "None"
Octopus.Action.Terraform.PlanJsonOutput = "False"
Octopus.Action.Terraform.RunAutomaticFileSubstitution = "True"
OctopusUseBundledTooling = "False"
Octopus.Action.Template.Id = "ActionTemplates-1"
Octopus.Action.Template.Version = "3"
}
worker_pool_variable = ""
@@ -29,15 +14,6 @@ step "plan-to-apply-a-terraform-template" {
feed = "nexus"
image = "#{TF_Container}"
}
packages {
acquisition_location = "Server"
feed = "nexus-nuget"
package_id = "#{TF_PACKAGE}"
properties = {
SelectionMode = "immediate"
}
}
}
}
@@ -45,16 +21,11 @@ step "approve-plan" {
name = "Approve Plan"
action {
action_type = "Octopus.Manual"
environments = ["development"]
is_required = true
properties = {
Octopus.Action.Manual.BlockConcurrentDeployments = "False"
Octopus.Action.Manual.Instructions = <<-EOT
```
#{Octopus.Action[Terraform Plan].Output.TerraformPlanOutput}
```
EOT
Octopus.Action.RunOnServer = "false"
Octopus.Action.Template.Id = "ActionTemplates-3"
Octopus.Action.Template.Version = "0"
}
}
}
@@ -63,24 +34,10 @@ step "terraform-apply" {
name = "Terraform Apply"
action {
action_type = "Octopus.TerraformApply"
properties = {
Octopus.Action.GoogleCloud.ImpersonateServiceAccount = "False"
Octopus.Action.GoogleCloud.UseVMServiceAccount = "True"
Octopus.Action.Package.DownloadOnTentacle = "False"
Octopus.Action.Package.FeedId = "nexus-nuget"
Octopus.Action.Package.PackageId = "#{TF_PACKAGE}"
Octopus.Action.RunOnServer = "true"
Octopus.Action.Script.ScriptSource = "Package"
Octopus.Action.Terraform.AdditionalInitParams = "#{TF_INIT}"
Octopus.Action.Terraform.AllowPluginDownloads = "True"
Octopus.Action.Terraform.AzureAccount = "False"
Octopus.Action.Terraform.EnvVariables = "{\"TF_VAR_GITLAB_PROJECT_ID\":\"#{GITLAB_PROJECT_ID}\",\"TF_VAR_GITLAB_PROJECT_NAME\":\"#{GITLAB_PROJECT_NAME}\",\"TF_VAR_GITLAB_SHARED_RUNNER_ID\":\"#{GITLAB_SHARED_RUNNER_ID}\",\"TF_VAR_GITLAB_TOKEN\":\"#{GITLAB_TOKEN}\",\"TF_VAR_OCTOAPI\":\"#{OCTOAPI}\"}"
Octopus.Action.Terraform.GoogleCloudAccount = "False"
Octopus.Action.Terraform.ManagedAccount = "None"
Octopus.Action.Terraform.PlanJsonOutput = "False"
Octopus.Action.Terraform.RunAutomaticFileSubstitution = "True"
OctopusUseBundledTooling = "False"
Octopus.Action.Template.Id = "ActionTemplates-2"
Octopus.Action.Template.Version = "1"
}
worker_pool_variable = ""
@@ -88,14 +45,5 @@ step "terraform-apply" {
feed = "nexus"
image = "#{TF_Container}"
}
packages {
acquisition_location = "Server"
feed = "nexus-nuget"
package_id = "#{TF_PACKAGE}"
properties = {
SelectionMode = "immediate"
}
}
}
}

View File

@@ -1,3 +1,5 @@
default_guided_failure_mode = "On"
connectivity_policy {
allow_deployments_to_no_targets = true
}

View File

@@ -1,11 +1,30 @@
variable "TF_INIT" {
value "-backend-config=\"address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/gitlab\" -backend-config=\"lock_address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/gitlab/lock\" -backend-config=\"unlock_address=https://gitlab.com/api/v4/projects/#{GITLAB_PROJECT_ID}/terraform/state/gitlab/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 "TF_PACKAGE" {
value "TERRAFORM.GITLAB.PROJECTS" {}
}
variable "TF_CONTAINER" {
value "developerdurp/octopus-packages" {}
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}" {}
}

View File

@@ -1,3 +1,4 @@
variables:
PROJECT_NAME: TERRAFORM.GITLAB.PROJECTS
OCTO_PROJECT_NAME: "Gitlab Projects"
PIPELINE: 'gitlab'
PROJECT_NAME: "TERRAFORM.GITLAB.PROJECTS"
OCTO_PROJECT_NAME: "Gitlab Projects"

View File

@@ -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

View 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
}

View 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
}

View File

@@ -5,50 +5,10 @@ terraform {
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" {
project = gitlab_project.project.id
runner_id = var.GITLAB_SHARED_RUNNER_ID
}
resource "gitlab_project_variable" "OCTOAPI" {
project = gitlab_project.project.id
key = "OCTOAPI"
value = var.OCTOAPI
protected = false
masked = true
}

View 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
}

View File

@@ -2,18 +2,30 @@ variable "GITLAB_TOKEN" {
type = string
}
variable "GITLAB_PROJECT_ID" {
type = number
}
variable "GITLAB_PROJECT_NAME" {
type = string
}
variable "GITLAB_SHARED_RUNNER_ID" {
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
}

View 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}"