Sha256: 4a26d454dcc2b9cb5f61e3af9dabb6975854390777b021fa14f8fbc5afa10c60

Contents?: true

Size: 1.91 KB

Versions: 53

Compression:

Stored size: 1.91 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",
#   "pdb_config": "A hash of PDB client config options as supplied to Bolt",
#   "hiera_config": "File path to hiera config file",
#   "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",
#     "trusted": "Hash of trusted data for the node"
#   },
#   "inventory": JSON serialized information about inventory {
#       "data": Data stored in inventory @data instance variable,
#       "target_hash": {
#         "target_vars": Vars that may have been updated plan,
#         "target_facts": Facts that may have been updated in plan,
#         "target_features": Features that may have been updated in plan,
#       },
#       "config": {
#         "transport": Transport to use,
#         "transports": Array of transport configs (note that transport keys are stringified)
#       }
#   }
# }

command = ARGV[0]
if command == "parse"
  code = File.open(ARGV[1], &:read)
  puts JSON.pretty_generate(Bolt::Catalog.new.generate_ast(code, ARGV[1]))
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)
  # This seems to be a string in ruby 2.3
  if catalog.is_a?(String)
    catalog = JSON.parse(catalog)
  end
  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

53 entries across 53 versions & 1 rubygems

Version Path
bolt-1.49.0 libexec/bolt_catalog
bolt-1.48.0 libexec/bolt_catalog
bolt-1.47.0 libexec/bolt_catalog
bolt-1.45.0 libexec/bolt_catalog
bolt-1.44.0 libexec/bolt_catalog
bolt-1.43.0 libexec/bolt_catalog
bolt-1.42.0 libexec/bolt_catalog
bolt-1.41.0 libexec/bolt_catalog
bolt-1.40.0 libexec/bolt_catalog
bolt-1.39.0 libexec/bolt_catalog
bolt-1.38.0 libexec/bolt_catalog
bolt-1.37.0 libexec/bolt_catalog
bolt-1.36.0 libexec/bolt_catalog
bolt-1.35.0 libexec/bolt_catalog
bolt-1.34.0 libexec/bolt_catalog
bolt-1.33.0 libexec/bolt_catalog
bolt-1.32.0 libexec/bolt_catalog
bolt-1.31.1 libexec/bolt_catalog
bolt-1.31.0 libexec/bolt_catalog
bolt-1.30.1 libexec/bolt_catalog