Skip to content

Instantly share code, notes, and snippets.

@ripienaar
Created May 7, 2019 06:56
Show Gist options
  • Save ripienaar/cc28b4b2039107a8967f53faed0e0b66 to your computer and use it in GitHub Desktop.
Save ripienaar/cc28b4b2039107a8967f53faed0e0b66 to your computer and use it in GitHub Desktop.
#!/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))
data = {
"$schema" => "https://choria.io/schemas/mcorpc/ddl/v1/agent.json",
"metadata" => ddl.meta,
"actions" => [],
}
ddl.actions.sort.each do |action|
data["actions"] << ddl.action_interface(action)
end
puts JSON.pretty_generate(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment