factor out TF http back-end settings (#564)
Some checks failed
deploy-infra / deploy (push) Failing after 4m22s
/ check-data-model (push) Successful in 30s
Nix flake checks / _complete (push) Successful in 31s
Nix flake checks / deployment-basic (push) Successful in 33s
Nix flake checks / deployment-cli (push) Successful in 43s
Nix flake checks / deployment-model-nixops4 (push) Successful in 31s
Nix flake checks / deployment-model-ssh (push) Successful in 21s
Nix flake checks / deployment-model-tf (push) Successful in 21s
Nix flake checks / deployment-model-tf-proxmox (push) Successful in 56s
Nix flake checks / deployment-panel (push) Successful in 1m48s
Nix flake checks / nixops-deployment-providers-default (push) Successful in 12s
Nix flake checks / nixops-deployment-providers-fedi201 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-forgejo-ci (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-test (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-vm02116 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-vm02187 (push) Successful in 11s
Nix flake checks / nixosConfigurations-fedi201 (push) Successful in 32s
Nix flake checks / nixosConfigurations-forgejo-ci (push) Successful in 18s
Nix flake checks / nixosConfigurations-test01 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test02 (push) Successful in 16s
Nix flake checks / nixosConfigurations-test03 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test04 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test05 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test06 (push) Successful in 16s
Nix flake checks / nixosConfigurations-test11 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test12 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test13 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test14 (push) Successful in 16s
Nix flake checks / nixosConfigurations-vm02116 (push) Successful in 18s
Nix flake checks / nixosConfigurations-vm02187 (push) Successful in 18s
Nix flake checks / panel (push) Successful in 29s
Nix flake checks / pre-commit (push) Successful in 11s
Nix flake checks / proxmox-basic (push) Successful in 34s
Nix flake checks / test-mastodon-service (push) Successful in 22s
Nix flake checks / test-peertube-service (push) Successful in 23s
Nix flake checks / vmOptions-fedi201 (push) Successful in 5s
Nix flake checks / vmOptions-test01 (push) Successful in 5s
Nix flake checks / vmOptions-test02 (push) Successful in 4s
Nix flake checks / vmOptions-test03 (push) Successful in 5s
Nix flake checks / vmOptions-test04 (push) Successful in 10s
Nix flake checks / vmOptions-test05 (push) Successful in 5s
Nix flake checks / vmOptions-test06 (push) Successful in 5s
Nix flake checks / vmOptions-test11 (push) Successful in 5s
Nix flake checks / vmOptions-test12 (push) Successful in 4s
Nix flake checks / vmOptions-test13 (push) Successful in 8s
Nix flake checks / vmOptions-test14 (push) Successful in 10s
Nix flake checks / _checks (push) Successful in 1s
Some checks failed
deploy-infra / deploy (push) Failing after 4m22s
/ check-data-model (push) Successful in 30s
Nix flake checks / _complete (push) Successful in 31s
Nix flake checks / deployment-basic (push) Successful in 33s
Nix flake checks / deployment-cli (push) Successful in 43s
Nix flake checks / deployment-model-nixops4 (push) Successful in 31s
Nix flake checks / deployment-model-ssh (push) Successful in 21s
Nix flake checks / deployment-model-tf (push) Successful in 21s
Nix flake checks / deployment-model-tf-proxmox (push) Successful in 56s
Nix flake checks / deployment-panel (push) Successful in 1m48s
Nix flake checks / nixops-deployment-providers-default (push) Successful in 12s
Nix flake checks / nixops-deployment-providers-fedi201 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-forgejo-ci (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-test (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-vm02116 (push) Successful in 11s
Nix flake checks / nixops-deployment-providers-vm02187 (push) Successful in 11s
Nix flake checks / nixosConfigurations-fedi201 (push) Successful in 32s
Nix flake checks / nixosConfigurations-forgejo-ci (push) Successful in 18s
Nix flake checks / nixosConfigurations-test01 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test02 (push) Successful in 16s
Nix flake checks / nixosConfigurations-test03 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test04 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test05 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test06 (push) Successful in 16s
Nix flake checks / nixosConfigurations-test11 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test12 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test13 (push) Successful in 17s
Nix flake checks / nixosConfigurations-test14 (push) Successful in 16s
Nix flake checks / nixosConfigurations-vm02116 (push) Successful in 18s
Nix flake checks / nixosConfigurations-vm02187 (push) Successful in 18s
Nix flake checks / panel (push) Successful in 29s
Nix flake checks / pre-commit (push) Successful in 11s
Nix flake checks / proxmox-basic (push) Successful in 34s
Nix flake checks / test-mastodon-service (push) Successful in 22s
Nix flake checks / test-peertube-service (push) Successful in 23s
Nix flake checks / vmOptions-fedi201 (push) Successful in 5s
Nix flake checks / vmOptions-test01 (push) Successful in 5s
Nix flake checks / vmOptions-test02 (push) Successful in 4s
Nix flake checks / vmOptions-test03 (push) Successful in 5s
Nix flake checks / vmOptions-test04 (push) Successful in 10s
Nix flake checks / vmOptions-test05 (push) Successful in 5s
Nix flake checks / vmOptions-test06 (push) Successful in 5s
Nix flake checks / vmOptions-test11 (push) Successful in 5s
Nix flake checks / vmOptions-test12 (push) Successful in 4s
Nix flake checks / vmOptions-test13 (push) Successful in 8s
Nix flake checks / vmOptions-test14 (push) Successful in 10s
Nix flake checks / _checks (push) Successful in 1s
Reviewed-on: #564
This commit is contained in:
parent
78f1ba3c91
commit
d5218ca66c
5 changed files with 93 additions and 30 deletions
|
|
@ -8,12 +8,8 @@
|
||||||
let
|
let
|
||||||
inherit (pkgs) system;
|
inherit (pkgs) system;
|
||||||
backendPort = builtins.toString 8080;
|
backendPort = builtins.toString 8080;
|
||||||
tfBackend = fragment: rec {
|
tfBackend = fragment: {
|
||||||
TF_HTTP_USERNAME = "basic";
|
address = "http://localhost:${backendPort}/state/${fragment}";
|
||||||
TF_HTTP_PASSWORD = "fake-secret";
|
|
||||||
TF_HTTP_LOCK_ADDRESS = TF_HTTP_ADDRESS;
|
|
||||||
TF_HTTP_UNLOCK_ADDRESS = TF_HTTP_ADDRESS;
|
|
||||||
TF_HTTP_ADDRESS = "http://localhost:${backendPort}/state/${fragment}";
|
|
||||||
};
|
};
|
||||||
template-deployment =
|
template-deployment =
|
||||||
(import ./setups/template.nix {
|
(import ./setups/template.nix {
|
||||||
|
|
|
||||||
|
|
@ -17,13 +17,7 @@ let
|
||||||
inherit nodeName pathToRoot;
|
inherit nodeName pathToRoot;
|
||||||
targetSystem = system;
|
targetSystem = system;
|
||||||
sshOpts = [ ];
|
sshOpts = [ ];
|
||||||
httpBackend = rec {
|
httpBackend.address = "http://localhost:${backendPort}/state/project1/example";
|
||||||
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;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
}).default.tf-host.run;
|
}).default.tf-host.run;
|
||||||
in
|
in
|
||||||
|
|
|
||||||
|
|
@ -74,6 +74,91 @@ let
|
||||||
description = "A NixOS configuration.";
|
description = "A NixOS configuration.";
|
||||||
type = raw;
|
type = raw;
|
||||||
};
|
};
|
||||||
|
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.submodule (http-backend: {
|
||||||
|
options = {
|
||||||
|
value = mkOption {
|
||||||
|
readOnly = true;
|
||||||
|
default = lib.mapAttrs' (k: v: lib.nameValuePair "TF_HTTP_${lib.toUpper k}" (builtins.toString v)) {
|
||||||
|
inherit (http-backend.config)
|
||||||
|
address
|
||||||
|
update_method
|
||||||
|
lock_address
|
||||||
|
lock_method
|
||||||
|
unlock_address
|
||||||
|
unlock_method
|
||||||
|
username
|
||||||
|
password
|
||||||
|
skip_cert_verification
|
||||||
|
retry_max
|
||||||
|
retry_wait_min
|
||||||
|
retry_wait_max
|
||||||
|
;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
address = mkOption {
|
||||||
|
description = "The address of the REST endpoint";
|
||||||
|
type = str;
|
||||||
|
};
|
||||||
|
update_method = mkOption {
|
||||||
|
description = "HTTP method to use when updating state.";
|
||||||
|
type = str;
|
||||||
|
default = "POST";
|
||||||
|
};
|
||||||
|
lock_address = mkOption {
|
||||||
|
description = "The address of the lock REST endpoint.";
|
||||||
|
type = str;
|
||||||
|
default = http-backend.config.address;
|
||||||
|
};
|
||||||
|
lock_method = mkOption {
|
||||||
|
description = "The HTTP method to use when locking.";
|
||||||
|
type = str;
|
||||||
|
default = "LOCK";
|
||||||
|
};
|
||||||
|
unlock_address = mkOption {
|
||||||
|
description = "The address of the unlock REST endpoint.";
|
||||||
|
type = str;
|
||||||
|
default = http-backend.config.address;
|
||||||
|
};
|
||||||
|
unlock_method = mkOption {
|
||||||
|
description = "The HTTP method to use when unlocking.";
|
||||||
|
type = str;
|
||||||
|
default = "UNLOCK";
|
||||||
|
};
|
||||||
|
username = mkOption {
|
||||||
|
description = "The username for HTTP basic authentication.";
|
||||||
|
type = str;
|
||||||
|
default = "basic";
|
||||||
|
};
|
||||||
|
password = mkOption {
|
||||||
|
description = "The password for HTTP basic authentication.";
|
||||||
|
type = str;
|
||||||
|
default = "fake-secret";
|
||||||
|
};
|
||||||
|
skip_cert_verification = mkOption {
|
||||||
|
description = "Whether to skip TLS verification.";
|
||||||
|
type = str;
|
||||||
|
default = "false";
|
||||||
|
};
|
||||||
|
retry_max = mkOption {
|
||||||
|
description = "The number of HTTP request retries.";
|
||||||
|
type = types.int;
|
||||||
|
default = 2;
|
||||||
|
};
|
||||||
|
retry_wait_min = mkOption {
|
||||||
|
description = "The minimum time in seconds to wait between HTTP request attempts.";
|
||||||
|
type = types.int;
|
||||||
|
default = 1;
|
||||||
|
};
|
||||||
|
retry_wait_max = mkOption {
|
||||||
|
description = "The maximum time in seconds to wait between HTTP request attempts.";
|
||||||
|
type = types.int;
|
||||||
|
default = 30;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
});
|
||||||
|
};
|
||||||
host-ssh = mkOption {
|
host-ssh = mkOption {
|
||||||
description = "SSH connection info to connect to a single host.";
|
description = "SSH connection info to connect to a single host.";
|
||||||
type = submodule {
|
type = submodule {
|
||||||
|
|
@ -195,7 +280,7 @@ let
|
||||||
description = "The architecture of the system to deploy to.";
|
description = "The architecture of the system to deploy to.";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
inherit nixos-configuration;
|
inherit httpBackend nixos-configuration;
|
||||||
ssh = host-ssh;
|
ssh = host-ssh;
|
||||||
caller = mkOption {
|
caller = mkOption {
|
||||||
description = "The calling module to obtain the NixOS configuration from.";
|
description = "The calling module to obtain the NixOS configuration from.";
|
||||||
|
|
@ -213,10 +298,6 @@ let
|
||||||
description = "The path to the root of the repository.";
|
description = "The path to the root of the repository.";
|
||||||
type = types.path;
|
type = types.path;
|
||||||
};
|
};
|
||||||
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.
|
||||||
|
|
@ -278,16 +359,12 @@ let
|
||||||
description = "The architecture of the system to deploy to.";
|
description = "The architecture of the system to deploy to.";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
inherit nixos-configuration;
|
inherit httpBackend nixos-configuration;
|
||||||
ssh = host-ssh;
|
ssh = host-ssh;
|
||||||
node-name = mkOption {
|
node-name = mkOption {
|
||||||
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);
|
|
||||||
};
|
|
||||||
imageDatastoreId = mkOption {
|
imageDatastoreId = mkOption {
|
||||||
description = "ID of the datastore of the image.";
|
description = "ID of the datastore of the image.";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
@ -366,7 +443,7 @@ let
|
||||||
description = "The architecture of the system to deploy to.";
|
description = "The architecture of the system to deploy to.";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
};
|
};
|
||||||
inherit nixos-configuration;
|
inherit httpBackend nixos-configuration;
|
||||||
ssh = host-ssh;
|
ssh = host-ssh;
|
||||||
caller = mkOption {
|
caller = mkOption {
|
||||||
description = "The calling module to obtain the NixOS configuration from.";
|
description = "The calling module to obtain the NixOS configuration from.";
|
||||||
|
|
@ -388,10 +465,6 @@ 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);
|
|
||||||
};
|
|
||||||
bridge = mkOption {
|
bridge = mkOption {
|
||||||
description = "The name of the network bridge (defaults to vmbr0).";
|
description = "The name of the network bridge (defaults to vmbr0).";
|
||||||
type = types.str;
|
type = types.str;
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,6 @@ pkgs.writeScriptBin "setup" ''
|
||||||
# suppress warning on architecture-specific generated lock file:
|
# suppress warning on architecture-specific generated lock file:
|
||||||
# `Warning: Incomplete lock file information for providers`.
|
# `Warning: Incomplete lock file information for providers`.
|
||||||
env TF_HTTP_RETRY_MAX=1 TF_HTTP_RETRY_WAIT_MIN=0 \
|
env TF_HTTP_RETRY_MAX=1 TF_HTTP_RETRY_WAIT_MIN=0 \
|
||||||
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend)} \
|
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend.value)} \
|
||||||
tofu init -input=false 1>/dev/null
|
tofu init -input=false 1>/dev/null
|
||||||
''
|
''
|
||||||
|
|
|
||||||
|
|
@ -56,7 +56,7 @@ rec {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} \
|
} \
|
||||||
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend)} \
|
${toString (lib.mapAttrsToList (k: v: "${k}=\"${toBash v}\"") httpBackend.value)} \
|
||||||
'';
|
'';
|
||||||
tfPackage = pkgs.callPackage ./run/${directory}/tf.nix { };
|
tfPackage = pkgs.callPackage ./run/${directory}/tf.nix { };
|
||||||
tf-env = pkgs.callPackage ./run/tf-env.nix {
|
tf-env = pkgs.callPackage ./run/tf-env.nix {
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue