Compare commits

...

2 Commits

Author SHA1 Message Date
4eef24bec5 ci: fixing libvirt connection
Some checks failed
continuous-integration/drone/pr Build is failing
2022-05-27 12:42:39 +02:00
bf43e01ab2 perm: manage nodes and daemonsets with ci 2022-05-27 12:42:10 +02:00
5 changed files with 49 additions and 4 deletions

View File

@@ -6,6 +6,8 @@ name: Terraform root module
environment: environment:
TF_IN_AUTOMATION: "1" TF_IN_AUTOMATION: "1"
GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -i $${PWD}/id_rsa" GIT_SSH_COMMAND: "ssh -o StrictHostKeyChecking=no -i $${PWD}/id_rsa"
TF_VAR_lawndale_libvirt_uri_transport: ssh
TF_VAR_lawndale_libvirt_uri_userhostport: "192.168.253.254:10022"
trigger: trigger:
ref: ref:
@@ -18,6 +20,7 @@ steps:
commands: commands:
- echo "$${CI_SSH_KEY}" | base64 -d > id_rsa - echo "$${CI_SSH_KEY}" | base64 -d > id_rsa
- chmod 600 id_rsa - chmod 600 id_rsa
- echo 'lawndale_libvirt_uri_extra = {"sshauth"="privkey","keyfile"="'$${PWD}'/id_rsa"}' >> ci.tfvars
- terraform init - terraform init
environment: environment:
CI_SSH_KEY: CI_SSH_KEY:
@@ -32,7 +35,7 @@ steps:
commands: commands:
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- cp -a id_rsa ~/.ssh/id_rsa - cp -a id_rsa ~/.ssh/id_rsa
- terraform plan -out .tfplan - terraform plan -var-file ci.tfvars -out .tfplan
environment: environment:
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: terraform-aws-key-id from_secret: terraform-aws-key-id
@@ -55,7 +58,7 @@ steps:
commands: commands:
- mkdir -p ~/.ssh - mkdir -p ~/.ssh
- cp -a id_rsa ~/.ssh/id_rsa - cp -a id_rsa ~/.ssh/id_rsa
- terraform apply .tfplan - terraform apply -var-file ci.tfvars .tfplan
environment: environment:
AWS_ACCESS_KEY_ID: AWS_ACCESS_KEY_ID:
from_secret: terraform-aws-key-id from_secret: terraform-aws-key-id
@@ -70,6 +73,6 @@ steps:
--- ---
kind: signature kind: signature
hmac: 698805937fd548b8265f65322cb6e9cd83689faeba99d3387ffb255701d53f5e hmac: ef5513e0943a9a8af92b43c9f29b638680fd92da235e6763a59ea821b22e4c7a
... ...

3
ci.tf
View File

@@ -38,6 +38,7 @@ resource "kubernetes_cluster_role" "ci_cd" {
"persistentvolumeclaims", "persistentvolumeclaims",
"pods", "pods",
"namespaces", "namespaces",
"nodes",
"secrets", "secrets",
"serviceaccounts", "serviceaccounts",
"services", "services",
@@ -48,8 +49,10 @@ resource "kubernetes_cluster_role" "ci_cd" {
rule { rule {
api_groups = ["apps"] api_groups = ["apps"]
resources = [ resources = [
"daemonsets",
"deployments", "deployments",
"replicasets", # needed for 'helm upgrade --wait' "replicasets", # needed for 'helm upgrade --wait'
"statefulsets",
] ]
verbs = ["create", "delete", "get", "list", "patch", "update", "watch"] verbs = ["create", "delete", "get", "list", "patch", "update", "watch"]
} }

View File

@@ -38,4 +38,13 @@ EehXHhbRmbtSZ7c4DrGeR2J0SZTyBQJfZczSGRvEiKyGNnyZlLVYKTTnV9b+aN3q
Xw+ilWL3boYsSiqVN6SIUA== Xw+ilWL3boYsSiqVN6SIUA==
-----END CERTIFICATE----- -----END CERTIFICATE-----
EOM EOM
lawndale_libvirt_uri_extra = join("&", [for k, v in var.lawndale_libvirt_uri_extra : format("%s=%s", urlencode(k), urlencode(v))])
lawndale_libvirt_uri = var.lawndale_libvirt_uri != null ? var.lawndale_libvirt_uri : format("qemu+%s://%s%s?%s",
var.lawndale_libvirt_uri_transport,
var.lawndale_libvirt_uri_userhostport,
var.lawndale_libvirt_uri_path,
local.lawndale_libvirt_uri_extra
)
} }

View File

@@ -53,7 +53,7 @@ provider "aws" {
provider "libvirt" { provider "libvirt" {
# no-pty ssh-rsa AAAAB3..... # no-pty ssh-rsa AAAAB3.....
uri = "qemu+ssh://lawndale-hyper.sch.bme.hu:10022/system?sshauth=privkey" uri = local.lawndale_libvirt_uri
} }
provider "dns" { provider "dns" {

View File

@@ -32,3 +32,33 @@ variable "lawndale_dns_key_algorithm" {
description = "DNSSEC key to use sigining the NSUPDATE queries for Lawndale" description = "DNSSEC key to use sigining the NSUPDATE queries for Lawndale"
default = "hmac-sha256" default = "hmac-sha256"
} }
variable "lawndale_libvirt_uri" {
type = string
description = "Libvirt URI to use accessing Lawndale hypervisor"
default = null
nullable = true
}
variable "lawndale_libvirt_uri_transport" {
type = string
description = "Transport protocol (could be ssh or tls) to dial Lawndale hypervisor"
}
variable "lawndale_libvirt_uri_userhostport" {
type = string
description = "Libvirt URI username, hostname or ip address, and port to reach lawndale hypervisor, in the format of `[username@]<hostname>[:port]`"
default = "lawndale-hyper"
}
variable "lawndale_libvirt_uri_path" {
type = string
description = "Libvirt URI path sent to the libvirt daemon"
default = "/system"
}
variable "lawndale_libvirt_uri_extra" {
type = map(any)
description = "Libvirt URI extra parameters [https://libvirt.org/uri.html#transport-configuration](See Libvirt transport configuration)"
default = {}
}