Sha256: 860674448090a94cab519eb46d2447a61c1f9604951db26af8d6b5153f4e6db9
Contents?: true
Size: 1.79 KB
Versions: 6
Compression:
Stored size: 1.79 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)) 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
6 entries across 6 versions & 1 rubygems