mid

module
v0.0.5 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2025 License: MIT

README

mid

Pulumi-native configuration management

[!CAUTION] This provider is PRE-ALPHA software and NOT fit for production use!

mid combines the simplicity of Ansible, the declarativeness of Nix, and the power of Pulumi to make server configuration management simple, easy, and fast. mid is a "middle ground" between all of them to give you just what you need with as minimal overhead as possible.

Design Principles

Goals
  • Agentless; do everything over SSH
  • Manage machines quickly and in parallel (like Ansible, but with even more parallelization).
  • Declarative and determinate (e.g. deleting the Pulumi resource should delete the associated thing on the server)
  • Mostly drop-in replacement for the remote module of the Pulumi Command Provider
Non-goals
  • Nix-levels of determinism - achieving fully deterministic systems means managing the entire world deterministically and that just isn't feasible. If you need/want that level of determinism, just use Nix and NixOS.
  • Interop with other CM systems (Ansible, Puppet, Salt) - At present, Ansible is being used as an execution engine but effort is being made to switch to a custom Go-based engine. As such, reusing facts, roles, or modules from other systems isn't on the roadmap. pulumi-ansible-provisioner might be of interest for using existing Ansible roles.
  • Pull-based or agent-based workflows - I'm hyperfocusing on push-based deployments to keep it simple. Check out my pulumi-aws-ec2-instance component resources for ideas on how to interop Ansible with EC2 userdata (or your cloud's equivalent).
Future-goals
  • Be usable by non-root (and non-sudo) - The vast majority of use cases require root and a fast majority of systems have sudo. Right now this is hardcoded but in the future it would be nice to have this be more flexible.
  • Pluggable module system - Right now everything baked into the provider but it might be nice to be able to expand it somehow.
  • More language support - Only Go, TypeScript, and YAML are supported at the moment since those are the only languages I use with Pulumi. Python support will most likely be next, followed by C# and Java.

Installation and usage

[!CAUTION] Again, this is PRE-ALPHA software. It is not fit for general use!

Go

Grab the module

go get github.com/sapslaj/mid/sdk

Set up a provider instance

// main.go
package main

import (
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/sapslaj/mid/sdk/go/mid"
	"github.com/sapslaj/mid/sdk/go/mid/resource"
	"github.com/sapslaj/mid/sdk/go/mid/types"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		provider, err := mid.NewProvider(ctx, "provider", &mid.ProviderArgs{
			Connection: &types.ConnectionArgs{
				// TODO: use ESC for this for something
				User:     pulumi.String("root"),
				Password: pulumi.String("hunter2"),
				Host:     pulumi.String("localhost"),
				Port:     pulumi.Float64(2222),
			},
		})
		if err != nil {
			return err
		}
		return nil
	})
}

Add some resources

// main.go

// ...
func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		// ...

		_, err = resource.NewPackage(ctx, "vim", nil, pulumi.Provider(provider))
		if err != nil {
			return err
		}

		return nil
	})
}

Go!

pulumi up
TypeScript

mid is not published on NPM yet. Set up GitHub Packages as an NPM registry for the @sapslaj scope first.

Then npm install

npm install --save @sapslaj/pulumi-mid

Set up a provider instance

// index.ts
import * as pulumi from "@pulumi/pulumi";
import * as mid from "@sapslaj/pulumi-mid";

const provider = new mid.Provider("provider", {
  connection: {
    // TODO: use ESC for this or something
    user: "root",
    password: "hunter2",
    host: "localhost",
    port: 2222,
  },
});

Add some resources

// ...
new mid.resource.Package("vim", {}, {
  provider: provider,
});

Go!

pulumi up

Directories

Path Synopsis
Code generated by ./hack/generate-agent-binaries DO NOT EDIT
Code generated by ./hack/generate-agent-binaries DO NOT EDIT
cmd/mid-agent command
rpc
pkg
env
ptr
syncmap
VERY slim wrapper around sync.Map with Go generics for that sweet sweet type safety
VERY slim wrapper around sync.Map with Go generics for that sweet sweet type safety
sdk module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL