Skip to content

Commit

Permalink
Merge pull request #49 from code0-tech/setup-server-administration-state
Browse files Browse the repository at this point in the history
Setup state for administration server
  • Loading branch information
Taucher2003 authored Jul 12, 2024
2 parents aeff8ac + d3e58e6 commit 5777c84
Show file tree
Hide file tree
Showing 5 changed files with 79 additions and 1 deletion.
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,14 @@ jobs:
SHOW_JOB_LOGS: none
env:
GLPA_C0_GH_REF: ${{ github.ref }}
GLPA_C0_SSH_KNOWN_HOSTS: ${{ vars.SSH_KNOWN_HOSTS }}
GLPA_C0_PIPELINE_SSH_KEY: ${{ secrets.PIPELINE_SSH_KEY }}
GLPA_TF_VAR_cloudflare_api_token: ${{ secrets.CLOUDFLARE_API_TOKEN }}
GLPA_TF_VAR_cloudflare_account_id: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
GLPA_TF_VAR_gitlab_api_token: ${{ secrets.GL_API_TOKEN }}
GLPA_TF_VAR_github_app_key: ${{ secrets.GH_TF_APP_KEY }}
GLPA_TF_VAR_server_administration_ip: ${{ secrets.SERVER_ADMINISTRATION_IP }}
GLPA_TF_VAR_server_administration_ssh_port: ${{ secrets.SERVER_ADMINISTRATION_SSH_PORT }}

- name: Find existing comment
uses: peter-evans/find-comment@v3
Expand Down
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,4 @@ terraform.rc
.terraform.lock.hcl
localTerraform.sh
setLocalVariables.sh
*.pem
/private/
27 changes: 27 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,15 @@ default:
tags:
- infra

.ssh:
before_script:
- IFS=
- mkdir ~/.ssh
- touch ~/.ssh/known_hosts
- echo $C0_SSH_KNOWN_HOSTS >> ~/.ssh/known_hosts
- eval `ssh-agent -s`
- echo "$C0_PIPELINE_SSH_KEY" | tr -d '\r' | ssh-add -

.tf:
image: registry.gitlab.com/gitlab-org/terraform-images/stable:latest
before_script:
Expand Down Expand Up @@ -62,3 +71,21 @@ tf-apply:main:
needs:
- tf-plan:main
variables: !reference ["tf-plan:main", variables]

tf-plan:server_administration:
extends:
- .tf-plan
before_script:
- !reference [.ssh, before_script]
- !reference [.tf, before_script]
variables:
TF_STATE_NAME: server_administration
TF_ROOT: 'envs/server_administration'

tf-apply:server_administration:
extends:
- .tf-apply
before_script: !reference [tf-plan:server_administration, before_script]
needs:
- tf-plan:server_administration
variables: !reference [tf-plan:server_administration, variables]
28 changes: 28 additions & 0 deletions envs/server_administration/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
terraform {
backend "http" {}

required_providers {
cloudflare = {
source = "cloudflare/cloudflare"
version = "4.37.0"
}
docker = {
source = "kreuzwerker/docker"
version = "3.0.2"
}
}
}

provider "cloudflare" {
api_token = var.cloudflare_api_token
}

provider "docker" {
host = "ssh://pipeline@${var.server_administration_ip}:${var.server_administration_ssh_port}"

cert_path = ""
}

resource "docker_network" "test" {
name = "test"
}
19 changes: 19 additions & 0 deletions envs/server_administration/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
variable "cloudflare_api_token" {
type = string
sensitive = true
}

variable "cloudflare_account_id" {
type = string
sensitive = true
}

variable "server_administration_ip" {
type = string
sensitive = true
}

variable "server_administration_ssh_port" {
type = string
sensitive = true
}

0 comments on commit 5777c84

Please sign in to comment.