forked from fediversity/fediversity
unlog steps
Signed-off-by: Kiara Grouwstra <kiara@procolix.eu>
This commit is contained in:
parent
c5351e85ce
commit
a8a62f00cf
8 changed files with 88 additions and 61 deletions
|
|
@ -369,6 +369,7 @@ let
|
||||||
inherit
|
inherit
|
||||||
args
|
args
|
||||||
deployment-name
|
deployment-name
|
||||||
|
httpBackend
|
||||||
proxmox-user
|
proxmox-user
|
||||||
proxmox-password
|
proxmox-password
|
||||||
node-name
|
node-name
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,8 @@ let
|
||||||
inherit system;
|
inherit system;
|
||||||
overlays = [ overlay ];
|
overlays = [ overlay ];
|
||||||
};
|
};
|
||||||
overlay = _: _: {
|
overlay = _: prev: {
|
||||||
|
terraform-backend = prev.callPackage ../../modules/terraform-backend/package.nix { };
|
||||||
inherit
|
inherit
|
||||||
(import "${sources.proxmox-nixos}/pkgs" {
|
(import "${sources.proxmox-nixos}/pkgs" {
|
||||||
craneLib = pkgs.callPackage "${sources.crane}/lib" { };
|
craneLib = pkgs.callPackage "${sources.crane}/lib" { };
|
||||||
|
|
|
||||||
|
|
@ -6,7 +6,16 @@
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
inherit (pkgs) system;
|
inherit (pkgs) system;
|
||||||
|
backendPort = builtins.toString 8080;
|
||||||
|
httpBackend = rec {
|
||||||
|
TF_HTTP_USERNAME = "basic";
|
||||||
|
TF_HTTP_PASSWORD = "fake-secret";
|
||||||
|
TF_HTTP_ADDRESS = "http://localhost:${backendPort}/state/project1/example";
|
||||||
|
TF_HTTP_LOCK_ADDRESS = TF_HTTP_ADDRESS;
|
||||||
|
TF_HTTP_UNLOCK_ADDRESS = TF_HTTP_ADDRESS;
|
||||||
|
};
|
||||||
deployment-config = {
|
deployment-config = {
|
||||||
|
inherit httpBackend;
|
||||||
inherit (import ./constants.nix) pathToRoot;
|
inherit (import ./constants.nix) pathToRoot;
|
||||||
nodeName = "pve";
|
nodeName = "pve";
|
||||||
targetSystem = system;
|
targetSystem = system;
|
||||||
|
|
@ -22,8 +31,6 @@ let
|
||||||
config = deployment-config;
|
config = deployment-config;
|
||||||
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
|
# opt not to pass `inputs`, as we could only pass serializable arguments through to its self-call
|
||||||
})."tf-proxmox-deployment".tf-proxmox-host;
|
})."tf-proxmox-deployment".tf-proxmox-host;
|
||||||
# tracking non-tarball downloads seems unsupported still in npins:
|
|
||||||
# https://github.com/andir/npins/issues/163
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
_class = "nixosTest";
|
_class = "nixosTest";
|
||||||
|
|
@ -46,6 +53,7 @@ in
|
||||||
password = "mytestpw";
|
password = "mytestpw";
|
||||||
hashedPasswordFile = lib.mkForce null;
|
hashedPasswordFile = lib.mkForce null;
|
||||||
};
|
};
|
||||||
|
# https://github.com/SaumonNet/proxmox-nixos/blob/main/modules/proxmox-ve/default.nix
|
||||||
services.proxmox-ve = {
|
services.proxmox-ve = {
|
||||||
enable = true;
|
enable = true;
|
||||||
ipAddress = "192.168.1.1";
|
ipAddress = "192.168.1.1";
|
||||||
|
|
@ -59,6 +67,10 @@ in
|
||||||
nodes.deployer =
|
nodes.deployer =
|
||||||
{ ... }:
|
{ ... }:
|
||||||
{
|
{
|
||||||
|
imports = [
|
||||||
|
../../modules/terraform-backend
|
||||||
|
];
|
||||||
|
|
||||||
nix.nixPath = [
|
nix.nixPath = [
|
||||||
(lib.concatStringsSep ":" (lib.mapAttrsToList (k: v: k + "=" + v) sources))
|
(lib.concatStringsSep ":" (lib.mapAttrsToList (k: v: k + "=" + v) sources))
|
||||||
];
|
];
|
||||||
|
|
@ -87,6 +99,13 @@ in
|
||||||
sources.nixpkgs
|
sources.nixpkgs
|
||||||
pkgs.vte
|
pkgs.vte
|
||||||
];
|
];
|
||||||
|
services.terraform-backend = {
|
||||||
|
enable = true;
|
||||||
|
settings = {
|
||||||
|
LISTEN_ADDR = ":${backendPort}";
|
||||||
|
KMS_KEY = "tsjxw9NjKUBUlzbTnD7orqIAdEmpGYRARvxD51jtY+o=";
|
||||||
|
};
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
extraTestScript = ''
|
extraTestScript = ''
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@
|
||||||
lib,
|
lib,
|
||||||
config,
|
config,
|
||||||
inputs,
|
inputs,
|
||||||
|
sources,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
let
|
let
|
||||||
|
|
@ -398,13 +399,13 @@ let
|
||||||
type = submodule (
|
type = submodule (
|
||||||
tf-host:
|
tf-host:
|
||||||
let
|
let
|
||||||
raw = {
|
# raw = {
|
||||||
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw.nix";
|
# # formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw.nix";
|
||||||
formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw-efi.nix";
|
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/raw-efi.nix";
|
||||||
formatAttr = "raw";
|
# formatAttr = "raw";
|
||||||
fileExtension = ".img";
|
# fileExtension = ".img";
|
||||||
};
|
# };
|
||||||
format = raw;
|
# format = raw;
|
||||||
# qcow = {
|
# qcow = {
|
||||||
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/qcow.nix";
|
# formatConfig = "${pkgs.nixos-generators}/share/nixos-generator/formats/qcow.nix";
|
||||||
# formatAttr = "qcow";
|
# formatAttr = "qcow";
|
||||||
|
|
@ -417,7 +418,7 @@ let
|
||||||
# fileExtension = ".qcow2";
|
# fileExtension = ".qcow2";
|
||||||
# };
|
# };
|
||||||
# format = qcow-efi;
|
# format = qcow-efi;
|
||||||
inherit (format) formatConfig fileExtension formatAttr;
|
# inherit (format) formatConfig fileExtension formatAttr;
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
|
@ -458,6 +459,10 @@ let
|
||||||
description = "the name of the ProxmoX node to use.";
|
description = "the name of the ProxmoX node to use.";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
|
httpBackend = mkOption {
|
||||||
|
description = "environment variables to configure the TF HTTP back-end, see <https://developer.hashicorp.com/terraform/language/backend/http#configuration-variables>";
|
||||||
|
type = types.attrsOf (types.either types.str types.int);
|
||||||
|
};
|
||||||
run = mkOption {
|
run = mkOption {
|
||||||
type = types.package;
|
type = types.package;
|
||||||
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
|
# error: The option `tf-deployment.tf-host.run' is read-only, but it's set multiple times.
|
||||||
|
|
@ -470,6 +475,7 @@ let
|
||||||
module
|
module
|
||||||
args
|
args
|
||||||
deployment-name
|
deployment-name
|
||||||
|
httpBackend
|
||||||
root-path
|
root-path
|
||||||
proxmox-user
|
proxmox-user
|
||||||
proxmox-password
|
proxmox-password
|
||||||
|
|
@ -541,7 +547,14 @@ let
|
||||||
ssh_user = username;
|
ssh_user = username;
|
||||||
node_name = node-name;
|
node_name = node-name;
|
||||||
};
|
};
|
||||||
tf-env = pkgs.callPackage ./run/tf-proxmox/tf-env.nix { };
|
tf-env = pkgs.callPackage ./run/tf-env.nix {
|
||||||
|
inherit httpBackend;
|
||||||
|
tfPackage = pkgs.callPackage ./run/tf-proxmox/tf.nix { };
|
||||||
|
tfDirs = [
|
||||||
|
"deployment/run/tf-single-host"
|
||||||
|
"deployment/run/tf-proxmox"
|
||||||
|
];
|
||||||
|
};
|
||||||
proxmox-host = "192.168.51.81"; # root@fediversity-proxmox
|
proxmox-host = "192.168.51.81"; # root@fediversity-proxmox
|
||||||
vm-names = [ "test14" ];
|
vm-names = [ "test14" ];
|
||||||
vm_name = "test14";
|
vm_name = "test14";
|
||||||
|
|
@ -555,7 +568,7 @@ let
|
||||||
(pkgs.callPackage ./run/tf-proxmox/tf.nix { inherit sources; })
|
(pkgs.callPackage ./run/tf-proxmox/tf.nix { inherit sources; })
|
||||||
])
|
])
|
||||||
''
|
''
|
||||||
set -xe
|
set -e
|
||||||
|
|
||||||
# bash ./infra/proxmox-remove.sh \
|
# bash ./infra/proxmox-remove.sh \
|
||||||
# --api-url "https://${proxmox-host}:8006/api2/json" \
|
# --api-url "https://${proxmox-host}:8006/api2/json" \
|
||||||
|
|
@ -580,6 +593,7 @@ let
|
||||||
ls -l /tmp/${name}.qcow2
|
ls -l /tmp/${name}.qcow2
|
||||||
|
|
||||||
env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
|
env ${toString (lib.mapAttrsToList (k: v: "TF_VAR_${k}=\"${toBash v}\"") environment)} \
|
||||||
|
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend)} \
|
||||||
TF_VAR_image=/tmp/${name}.qcow2 \
|
TF_VAR_image=/tmp/${name}.qcow2 \
|
||||||
tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh
|
tf_env=${tf-env} bash ./deployment/run/tf-proxmox/run.sh
|
||||||
'';
|
'';
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,8 @@ terraform {
|
||||||
version = "= 0.81.0"
|
version = "= 0.81.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
backend "http" {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
locals {
|
locals {
|
||||||
|
|
@ -142,6 +144,7 @@ resource "proxmox_virtual_environment_vm" "nix_vm" {
|
||||||
cache = "none"
|
cache = "none"
|
||||||
|
|
||||||
# FIXME make the provider allow this as a distinct block to allow making this depend on VM id?
|
# FIXME make the provider allow this as a distinct block to allow making this depend on VM id?
|
||||||
|
# FIXME replace with an effectful ~~function~~template from vm_id replacing resource `proxmox_virtual_environment_file.upload`
|
||||||
# import_from = "local:import/${proxmox_virtual_environment_vm.nix_vm.vm_id}-${local.dump_name}" # bogus import name to test if it would accept self-referential values here # may not refer to itself
|
# import_from = "local:import/${proxmox_virtual_environment_vm.nix_vm.vm_id}-${local.dump_name}" # bogus import name to test if it would accept self-referential values here # may not refer to itself
|
||||||
# import_from = "local:import/${local.dump_name}"
|
# import_from = "local:import/${local.dump_name}"
|
||||||
import_from = proxmox_virtual_environment_file.upload.id
|
import_from = proxmox_virtual_environment_file.upload.id
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#! /usr/bin/env bash
|
#! /usr/bin/env bash
|
||||||
set -xeuo pipefail
|
set -euo pipefail
|
||||||
declare tf_env
|
declare tf_env
|
||||||
|
|
||||||
export TF_LOG=info
|
export TF_LOG=info
|
||||||
|
|
@ -8,4 +8,4 @@ export TF_LOG=info
|
||||||
|
|
||||||
cd "${tf_env}/deployment/run/tf-proxmox"
|
cd "${tf_env}/deployment/run/tf-proxmox"
|
||||||
# parallelism=1: limit OOM risk
|
# parallelism=1: limit OOM risk
|
||||||
tofu apply --auto-approve -lock=false -input=false -parallelism=1
|
tofu apply --auto-approve -input=false -parallelism=1
|
||||||
|
|
|
||||||
|
|
@ -1,33 +0,0 @@
|
||||||
{
|
|
||||||
lib,
|
|
||||||
pkgs,
|
|
||||||
sources ? import ../../../npins,
|
|
||||||
}:
|
|
||||||
pkgs.stdenv.mkDerivation {
|
|
||||||
name = "tf-repo";
|
|
||||||
src =
|
|
||||||
with lib.fileset;
|
|
||||||
toSource {
|
|
||||||
root = ../../../.;
|
|
||||||
# don't copy ignored files
|
|
||||||
fileset = intersection (gitTracked ../../../.) ../../../.;
|
|
||||||
};
|
|
||||||
buildInputs = [
|
|
||||||
(pkgs.callPackage ./tf.nix { inherit sources; })
|
|
||||||
(pkgs.callPackage ../tf-setup.nix { inherit sources; })
|
|
||||||
];
|
|
||||||
buildPhase = ''
|
|
||||||
runHook preBuild
|
|
||||||
for category in deployment/run/tf-single-host deployment/run/tf-proxmox; do
|
|
||||||
pushd "$category"
|
|
||||||
source setup
|
|
||||||
popd
|
|
||||||
done
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
|
||||||
installPhase = ''
|
|
||||||
runHook preInstall
|
|
||||||
cp -r . $out
|
|
||||||
runHook postInstall
|
|
||||||
'';
|
|
||||||
}
|
|
||||||
|
|
@ -4,6 +4,8 @@
|
||||||
sources ? import ../../../npins,
|
sources ? import ../../../npins,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
|
# FIXME centralize overlays
|
||||||
|
# XXX using recent revision for https://github.com/NixOS/nixpkgs/pull/447849
|
||||||
let
|
let
|
||||||
mkProvider =
|
mkProvider =
|
||||||
args:
|
args:
|
||||||
|
|
@ -11,17 +13,37 @@ let
|
||||||
{ mkProviderFetcher = { repo, ... }: sources.${repo}; } // args
|
{ mkProviderFetcher = { repo, ... }: sources.${repo}; } // args
|
||||||
);
|
);
|
||||||
in
|
in
|
||||||
pkgs.opentofu.withPlugins (p: [
|
(
|
||||||
p.external
|
(pkgs.callPackage "${sources.nixpkgs-unstable}/pkgs/by-name/op/opentofu/package.nix" { })
|
||||||
(mkProvider {
|
.overrideAttrs
|
||||||
owner = "bpg";
|
(old: rec {
|
||||||
repo = "terraform-provider-proxmox";
|
patches = (old.patches or [ ]) ++ [
|
||||||
# 0.82+ need go 1.25
|
# TF with back-end poses a problem for nix: initialization involves both
|
||||||
rev = "v0.81.0";
|
# mutation (nix: only inside build) and a network call (nix: not inside build)
|
||||||
spdx = "MPL-2.0";
|
../../check/data-model-tf/02-opentofu-sandboxed-init.patch
|
||||||
hash = null;
|
];
|
||||||
vendorHash = "sha256-cpei22LkKqohlE76CQcIL5d7p+BjNcD6UQ8dl0WXUOc=";
|
# versions > 1.9.0 need go 1.24+
|
||||||
homepage = "https://registry.terraform.io/providers/bpg/proxmox";
|
version = "1.9.0";
|
||||||
provider-source-address = "registry.opentofu.org/bpg/proxmox";
|
src = pkgs.fetchFromGitHub {
|
||||||
|
owner = "opentofu";
|
||||||
|
repo = "opentofu";
|
||||||
|
tag = "v${version}";
|
||||||
|
hash = "sha256-e0ZzbQdex0DD7Bj9WpcVI5roh0cMbJuNr5nsSVaOSu4=";
|
||||||
|
};
|
||||||
|
vendorHash = "sha256-fMTbLSeW+pw6GK8/JLZzG2ER90ss2g1FSDX5+f292do=";
|
||||||
})
|
})
|
||||||
])
|
).withPlugins
|
||||||
|
(p: [
|
||||||
|
p.external
|
||||||
|
(mkProvider {
|
||||||
|
owner = "bpg";
|
||||||
|
repo = "terraform-provider-proxmox";
|
||||||
|
# 0.82+ need go 1.25
|
||||||
|
rev = "v0.81.0";
|
||||||
|
spdx = "MPL-2.0";
|
||||||
|
hash = null;
|
||||||
|
vendorHash = "sha256-cpei22LkKqohlE76CQcIL5d7p+BjNcD6UQ8dl0WXUOc=";
|
||||||
|
homepage = "https://registry.terraform.io/providers/bpg/proxmox";
|
||||||
|
provider-source-address = "registry.opentofu.org/bpg/proxmox";
|
||||||
|
})
|
||||||
|
])
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue