Sha256: 4676c4e859f9bc2b1c6f08f0235b236b1931a12b72819267fcb56201573166a5

Contents?: true

Size: 1.13 KB

Versions: 16

Compression:

Stored size: 1.13 KB

Contents

#! /opt/puppetlabs/puppet/bin/ruby
# frozen_string_literal: true

require 'json'
require 'puppet'
require 'puppet/module_tool/tar'
require 'tempfile'

args = JSON.parse(STDIN.read)

Dir.mktmpdir do |puppet_root|
  # Create temporary directories for all core Puppet settings so we don't clobber
  # existing state or read from puppet.conf. Also create a temporary modulepath.
  moduledir = File.join(puppet_root, 'modules')
  Dir.mkdir(moduledir)
  cli = Puppet::Settings::REQUIRED_APP_SETTINGS.flat_map do |setting|
    ["--#{setting}", File.join(puppet_root, setting.to_s.chomp('dir'))]
  end
  cli << '--modulepath' << moduledir
  Puppet.initialize_settings(cli)

  Tempfile.open('plugins.tar.gz') do |plugins|
    File.binwrite(plugins, Base64.decode64(args['plugins']))
    Puppet::ModuleTool::Tar.instance.unpack(plugins, moduledir, Etc.getlogin || Etc.getpwuid.name)
  end

  env = Puppet.lookup(:environments).get('production')
  env.each_plugin_directory do |dir|
    $LOAD_PATH << dir unless $LOAD_PATH.include?(dir)
  end

  facts = Puppet::Node::Facts.indirection.find(SecureRandom.uuid, environment: env)
  puts(facts.values.to_json)
end

exit 0

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
bolt-1.13.1 libexec/custom_facts.rb
bolt-1.13.0 libexec/custom_facts.rb
bolt-1.12.0 libexec/custom_facts.rb
bolt-1.11.0 libexec/custom_facts.rb
bolt-1.10.0 libexec/custom_facts.rb
bolt-1.9.0 libexec/custom_facts.rb
bolt-1.8.1 libexec/custom_facts.rb
bolt-1.8.0 libexec/custom_facts.rb
bolt-1.7.0 libexec/custom_facts.rb
bolt-1.6.0 libexec/custom_facts.rb
bolt-1.5.0 libexec/custom_facts.rb
bolt-1.4.0 libexec/custom_facts.rb
bolt-1.3.0 libexec/custom_facts.rb
bolt-1.2.0 libexec/custom_facts.rb
bolt-1.1.0 libexec/custom_facts.rb
bolt-1.0.0 libexec/custom_facts.rb