Sha256: cb896062c6dd5d97cb9a2b9b35be91e7a997462ce25f54c8116224f6da1df228

Contents?: true

Size: 1.08 KB

Versions: 2

Compression:

Stored size: 1.08 KB

Contents

#!/usr/bin/env ruby
# frozen_string_literal: true

require 'bolt'
require 'bolt/catalog'
require 'json'

# This accepts a catalog request on stdin:
# { "code_ast": "JSON serialized Puppet AST",
#   "code_string": "String of code, ignored if AST is provided,
#   "modulepath": "Array of directories to use as the modulepath for catalog compilation.
#   "target": {
#   "name": "the name of the node usually fqdn fro url",
#   "facts": "Hash of facts to use for the node",
#   "variables": "Hash of variables to use for compilation"
#   }
# }

command = ARGV[0]
if command == "parse"
  code = File.open(ARGV[1], &:read)
  puts JSON.pretty_generate(Bolt::Catalog.new.generate_ast(code))
elsif command == "compile"
  request = if ARGV[1]
              File.open(ARGV[1]) { |fh| JSON.parse(fh.read) }
            else
              JSON.parse(STDIN.read)
            end
  catalog = Bolt::Catalog.new.compile_catalog(request)
  puts JSON.pretty_generate(catalog)
else
  puts "USAGE: run 'bolt_catalog compile' with a request on STDIN " \
       "or 'bolt_catalog parse manifest.pp' to generate JSON AST"
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bolt-0.21.2 libexec/bolt_catalog
bolt-0.21.1 exe/bolt_catalog