UNCLASSIFIED

Skip to content
Snippets Groups Projects
Commit db0d39d8 authored by kmc-home's avatar kmc-home
Browse files

add cicd

parent dccdc50d
No related merge requests found
Pipeline #119486 failed
variables:
RUN_HELLO_WORLD:
description: "Variable to trigger the hello-world pipeline"
value: ""
options:
- ""
- "true"
- "false"
include:
- local: pipelines/hello-world.yml
rules:
- if: $RUN_HELLO_WORLD == "true"
# Simple .gitlab-ci.yml file (shell executor by default)
stages:
- build
hello_world:
stage: build
script:
- echo "Hello, World!"
\ No newline at end of file
# What is GitLab CI/CD?
GitLab CI/CD is a powerful built-in tool that allows you to automate the building, testing, and deployment of your applications. It uses a YAML file called .gitlab-ci.yml in your project's root directory to define your CI/CD pipeline.
## Key Concepts
- **Pipeline**: A series of stages that define the workflow of your CI/CD process.
- **Stage**: A logical grouping of jobs, such as build, test, and deploy.
- **Job**: A single unit of work, such as compiling code, running tests, or deploying an application.
- **Runner**: An agent that executes jobs. Runners can be shared, specific to a project, or your own.
- **Executor**: The environment in which a job runs. Examples include shell, docker, and kubernetes.
```yaml
# Simple .gitlab-ci.yml file (shell executor by default)
stages:
- build
hello_world:
stage: build
script:
- echo "Hello, World!"
```
```yaml
# Simple app .gitlab-ci.yml (shell executor by default)
stages:
- build
- test
build:
stage: build
script:
- echo "Building the application..."
- mkdir build
- cd build
- cmake ..
- make
test:
stage: test
script:
- echo "Running tests..."
- cd build
- ctest
```
# Provider configuration
terraform {
required_providers {
openstack = {
source = "terraform-provider-openstack/openstack"
}
}
}
# Data
data "openstack_networking_network_v2" "public" {
name = "public"
}
# Variables
variable "username" {
type = string
description = "Sets the login username for the instances"
default = "student"
}
variable "password" {
type = string
description = "Sets the Login Password for the instances"
default = "password"
sensitive = true
}
variable "public_key" {
type = string
description = "Sets the public key for the instances"
default = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIwofrs+eeWoyxUZH89SgPsZbxn2sgpUOTd7n3LqoDdi woac-infra-demo"
}
# Random string generation
resource "random_string" "suffix" {
length = 4
special = false
}
# Network Configuration
resource "openstack_networking_network_v2" "ops_network_test" {
name = "ops_network_test_${random_string.suffix.result}"
admin_state_up = true
}
resource "openstack_networking_subnet_v2" "ops_subnet_test" {
name = "ops_subnet_test"
network_id = openstack_networking_network_v2.ops_network_test.id
cidr = "192.168.65.0/27"
gateway_ip = "192.168.65.30"
dns_nameservers = ["10.50.255.254"]
ip_version = 4
}
# Router Configuration
resource "openstack_networking_router_v2" "ops_router_test" {
name = "ops_router_test"
external_network_id = data.openstack_networking_network_v2.public.id
}
resource "openstack_networking_router_interface_v2" "ops_router_interface_test" {
router_id = openstack_networking_router_v2.ops_router_test.id
subnet_id = openstack_networking_subnet_v2.ops_subnet_test.id
}
# Linux Analyst Workstation Port
resource "openstack_networking_port_v2" "linux_opstation_port_test" {
name = "linux_opstation_port_test"
network_id = openstack_networking_network_v2.ops_network_test.id
port_security_enabled = false
fixed_ip {
subnet_id = openstack_networking_subnet_v2.ops_subnet_test.id
ip_address = "192.168.65.20"
}
}
# Floating IP Configuration
resource "openstack_networking_floatingip_v2" "linux_opstation_float_ip_test" {
pool = "public"
}
resource "openstack_networking_floatingip_associate_v2" "linux_opstation_float_ip_assoc_test" {
floating_ip = openstack_networking_floatingip_v2.linux_opstation_float_ip_test.address
port_id = openstack_networking_port_v2.linux_opstation_port_test.id
}
# Linux Analyst Workstation Instance
resource "openstack_compute_instance_v2" "linux_opstation_test" {
name = "linux_opstation_test"
image_name = "delta_ops"
flavor_name = "m4.medium.2"
config_drive = true
user_data = templatefile("${path.module}/ud.sh", {
username = var.username
password = var.password
public_key = var.public_key
})
network {
port = openstack_networking_port_v2.linux_opstation_port_test.id
}
}
\ No newline at end of file
#!/bin/bash
echo "Hello From User Data"
useradd username
\ No newline at end of file
......@@ -11,14 +11,14 @@ variable "prefix" {
# The following variables are required to be declared in the root module so we can set their values in terraform.tfvars
# These are more strictly defined in their respective ./module/<MODULE NAME>/vars.tf file or directly in ./module/<MODULE_NAME>/<MODULE_NAME>.tf
# variable "sec_groups" {
# type = map(any)
# }
variable "sec_groups" {
type = map(any)
}
# variable "nets" {
# type = map(any)
# }
variable "nets" {
type = map(any)
}
# variable "instances" {
# type = map(any)
# }
\ No newline at end of file
variable "instances" {
type = map(any)
}
\ No newline at end of file
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment