Use Pulumi to provision and Nix to configure (#12)

This commit is contained in:
Patrick Stevens
2023-02-02 22:14:16 +00:00
committed by GitHub
parent 61611ccc2c
commit d08cf9bec3
46 changed files with 810 additions and 1165 deletions

View File

@@ -1,19 +1,12 @@
namespace PulumiWebServer
open System.Diagnostics
open Pulumi
open Pulumi.Command.Local
[<RequireQualifiedAccess>]
module Local =
let forgetKey (address : Address) : unit =
let address = address.Get ()
let psi = ProcessStartInfo "/usr/bin/ssh-keygen"
psi.Arguments <- $"-R {address}"
psi.RedirectStandardError <- true
psi.RedirectStandardOutput <- true
psi.UseShellExecute <- false
let proc = psi |> Process.Start
proc.WaitForExit ()
let error = proc.StandardOutput.ReadToEnd ()
// We don't expect to have configured SSH yet, so this is fine.
if proc.ExitCode <> 0 then
failwith $"Unexpectedly failed to forget key: {address} ({proc.ExitCode}). {error}"
let forgetKey (address : string) : Command =
let args = CommandArgs ()
args.Create <- Input.lift $"/usr/bin/ssh-keygen -R {address} || exit 0"
Command ($"forget-key-{address}", args)