From 119997e273a23daff32a360b24cbde3c45a89afd Mon Sep 17 00:00:00 2001 From: Tamas Kiss Date: Fri, 27 May 2022 12:42:39 +0200 Subject: [PATCH] ci: fixing libvirt connection --- .drone.yml | 13 ++++++------- locals.tf | 9 +++++++++ providers.tf | 2 +- variables.tf | 30 ++++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 8 deletions(-) diff --git a/.drone.yml b/.drone.yml index ca3ac6b..dd6d5e2 100644 --- a/.drone.yml +++ b/.drone.yml @@ -6,6 +6,8 @@ name: Terraform root module environment: TF_IN_AUTOMATION: "1" 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: ref: @@ -18,6 +20,7 @@ steps: commands: - echo "$${CI_SSH_KEY}" | base64 -d > id_rsa - chmod 600 id_rsa + - echo 'lawndale_libvirt_uri_extra = {"sshauth"="privkey","keyfile"="'$${PWD}'/id_rsa","no_verify"="1"}' >> ci.tfvars - terraform init environment: CI_SSH_KEY: @@ -30,9 +33,7 @@ steps: - name: terraform plan image: hashicorp/terraform:1.1.8 commands: - - mkdir -p ~/.ssh - - cp -a id_rsa ~/.ssh/id_rsa - - terraform plan -out .tfplan + - terraform plan -var-file ci.tfvars -out .tfplan environment: AWS_ACCESS_KEY_ID: from_secret: terraform-aws-key-id @@ -53,9 +54,7 @@ steps: - push image: hashicorp/terraform:1.1.8 commands: - - mkdir -p ~/.ssh - - cp -a id_rsa ~/.ssh/id_rsa - - terraform apply .tfplan + - terraform apply -var-file ci.tfvars .tfplan environment: AWS_ACCESS_KEY_ID: from_secret: terraform-aws-key-id @@ -70,6 +69,6 @@ steps: --- kind: signature -hmac: 698805937fd548b8265f65322cb6e9cd83689faeba99d3387ffb255701d53f5e +hmac: 007cc7fc0dbdc2ae54a59dbc6c673e33e4f94831189eb3b6fd4b0b0f8adf703f ... diff --git a/locals.tf b/locals.tf index 010f0eb..f7be528 100644 --- a/locals.tf +++ b/locals.tf @@ -38,4 +38,13 @@ EehXHhbRmbtSZ7c4DrGeR2J0SZTyBQJfZczSGRvEiKyGNnyZlLVYKTTnV9b+aN3q Xw+ilWL3boYsSiqVN6SIUA== -----END CERTIFICATE----- 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 + ) } \ No newline at end of file diff --git a/providers.tf b/providers.tf index e490f65..4023b18 100644 --- a/providers.tf +++ b/providers.tf @@ -53,7 +53,7 @@ provider "aws" { provider "libvirt" { # no-pty ssh-rsa AAAAB3..... - uri = "qemu+ssh://lawndale-hyper.sch.bme.hu:10022/system?sshauth=privkey" + uri = local.lawndale_libvirt_uri } provider "dns" { diff --git a/variables.tf b/variables.tf index 5db4a65..131b1f0 100644 --- a/variables.tf +++ b/variables.tf @@ -32,3 +32,33 @@ variable "lawndale_dns_key_algorithm" { description = "DNSSEC key to use sigining the NSUPDATE queries for Lawndale" 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@][: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 = {} +}