Skip to content

Instantly share code, notes, and snippets.

View ripienaar's full-sized avatar

R.I.Pienaar ripienaar

View GitHub Profile
{
"$schema": "http://json-schema.org/draft-04/schema",
"id": "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
"type": "object",
"definitions": {
"shortname": {
"type": "string",
"minLength": 1,
"pattern": "^[a-z0-9_]*$"
},
@ripienaar
ripienaar / spec.md
Last active September 12, 2019 21:43

DRAFT Choria External Agents Spec

We would like to enable people to write agents in any language, this is a draft specification to show how we'll implement that feature.

Structure

External agents will live in one of several directories and have a format like:

-rwxr-xr-x 1 root root 315 Sep 12 11:18 helloworld
package main
import (
"context"
"fmt"
cc "github.com/ripienaar/rpcwrapperpoc/choriautil"
)
func main() {
c, err := cc.New()
// +build cgo
package choria
import (
"github.com/choria-io/go-security/pkcs11sec"
)
func (fw *Framework) setupPKCS11() (err error) {
fw.security, err = pkcs11sec.New(pkcs11sec.WithChoriaConfig(fw.Config), pkcs11sec.WithLog(fw.Logger("security")))
$ time ./go-choria req rpcutil ping --nodes list --display failed
40584 / 40584 1s [====================================================================] 100%
Finished processing 40584 / 40584 hosts in 1.83326912s
real 0m1.930s
user 0m3.661s
sys 0m0.862s
% ./go-choria req rpcutil ping -I /^dev\\d/
Discovering nodes .... 6
6 / 6 0s [====================================================================] 100%
dev7.devco.net
{
"pong": 1567603471
}
% choria buildinfo
Choria build settings:
Build Data:
Version: 0.11.0
Git SHA: unknown
Build Date: unknown
License: Apache-2.0
Go Version: go1.12.6
package main
import (
"context"
"fmt"
"strings"
"time"
"github.com/choria-io/go-choria/choria"
"github.com/choria-io/go-client/discovery/broadcast"
# .puppetlabs/etc/code/modules/acme/lib/puppet/functions/acme/callstack.rb
Puppet::Functions.create_function(:'acme::callstack') do
dispatch :stack do
end
def stack
Puppet::Pops::PuppetStack.stacktrace()
end
end
#!/opt/puppetlabs/puppet/bin/ruby
require "mcollective"
ddlfile = ARGV.shift
abort("Please specify an input DDL as argument") unless ddlfile
ddl = MCollective::DDL.new(File.basename(ddlfile, ".ddl"), :agent, false)
ddl.instance_eval(File.read(ddlfile))