feat: initial commit
This commit is contained in:
commit
38f495e3f4
457 changed files with 40577 additions and 0 deletions
21
environments/production/thirdparty/stdlib/lib/facter/package_provider.rb
vendored
Normal file
21
environments/production/thirdparty/stdlib/lib/facter/package_provider.rb
vendored
Normal file
|
@ -0,0 +1,21 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Fact: package_provider
|
||||
#
|
||||
# Purpose: Returns the default provider Puppet will choose to manage packages
|
||||
# on this system
|
||||
#
|
||||
# Resolution: Instantiates a dummy package resource and return the provider
|
||||
#
|
||||
# Caveats:
|
||||
#
|
||||
require 'puppet/type'
|
||||
require 'puppet/type/package'
|
||||
|
||||
# These will be nil if Puppet is not available.
|
||||
Facter.add(:package_provider) do
|
||||
# Instantiates a dummy package resource and return the provider
|
||||
setcode do
|
||||
Puppet::Type.type(:package).newpackage(name: 'dummy', allow_virtual: 'true')[:provider].to_s
|
||||
end
|
||||
end
|
62
environments/production/thirdparty/stdlib/lib/facter/pe_version.rb
vendored
Normal file
62
environments/production/thirdparty/stdlib/lib/facter/pe_version.rb
vendored
Normal file
|
@ -0,0 +1,62 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Fact: is_pe, pe_version, pe_major_version, pe_minor_version, pe_patch_version
|
||||
#
|
||||
# Purpose: Return various facts about the PE state of the system
|
||||
#
|
||||
# Resolution: Uses a regex match against puppetversion to determine whether the
|
||||
# machine has Puppet Enterprise installed, and what version (overall, major,
|
||||
# minor, patch) is installed.
|
||||
#
|
||||
# Caveats:
|
||||
#
|
||||
# Fact: pe_version
|
||||
Facter.add('pe_version') do
|
||||
setcode do
|
||||
found_version = Facter.value('pe_build')
|
||||
|
||||
unless found_version
|
||||
puppet_ver = Facter.value('puppetversion')
|
||||
unless puppet_ver.nil?
|
||||
pe_ver = puppet_ver.match(%r{Puppet Enterprise (\d+\.\d+\.\d+)})
|
||||
found_version = pe_ver[1] if pe_ver
|
||||
end
|
||||
end
|
||||
|
||||
found_version
|
||||
end
|
||||
end
|
||||
|
||||
# Fact: is_pe
|
||||
Facter.add('is_pe') do
|
||||
setcode do
|
||||
!Facter.value(:pe_version).to_s.empty?
|
||||
end
|
||||
end
|
||||
|
||||
# Fact: pe_major_version
|
||||
Facter.add('pe_major_version') do
|
||||
confine is_pe: true
|
||||
setcode do
|
||||
pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[0] if pe_version
|
||||
end
|
||||
end
|
||||
|
||||
# Fact: pe_minor_version
|
||||
Facter.add('pe_minor_version') do
|
||||
confine is_pe: true
|
||||
setcode do
|
||||
pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[1] if pe_version
|
||||
end
|
||||
end
|
||||
|
||||
# Fact: pe_patch_version
|
||||
Facter.add('pe_patch_version') do
|
||||
confine is_pe: true
|
||||
setcode do
|
||||
pe_version = Facter.value(:pe_version)
|
||||
pe_version.to_s.split('.')[2] if pe_version
|
||||
end
|
||||
end
|
46
environments/production/thirdparty/stdlib/lib/facter/puppet_settings.rb
vendored
Normal file
46
environments/production/thirdparty/stdlib/lib/facter/puppet_settings.rb
vendored
Normal file
|
@ -0,0 +1,46 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# These facter facts return the value of the Puppet vardir and environment path
|
||||
# settings for the node running puppet or puppet agent. The intent is to
|
||||
# enable Puppet modules to automatically have insight into a place where they
|
||||
# can place variable data, or for modules running on the puppet server to know
|
||||
# where environments are stored.
|
||||
#
|
||||
# The values should be directly usable in a File resource path attribute.
|
||||
#
|
||||
begin
|
||||
require 'facter/util/puppet_settings'
|
||||
rescue LoadError => e
|
||||
# puppet apply does not add module lib directories to the $LOAD_PATH (See
|
||||
# #4248). It should (in the future) but for the time being we need to be
|
||||
# defensive which is what this rescue block is doing.
|
||||
rb_file = File.join(File.dirname(__FILE__), 'util', 'puppet_settings.rb')
|
||||
load rb_file if File.exist?(rb_file) || raise(e)
|
||||
end
|
||||
|
||||
# Facter fact returns the value of the Puppet vardir
|
||||
Facter.add(:puppet_vardir) do
|
||||
setcode do
|
||||
Facter::Util::PuppetSettings.with_puppet do
|
||||
Puppet[:vardir]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Facter fact returns the value of the Puppet environment path
|
||||
Facter.add(:puppet_environmentpath) do
|
||||
setcode do
|
||||
Facter::Util::PuppetSettings.with_puppet do
|
||||
Puppet[:environmentpath]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# Facter fact returns the value of the Puppet server
|
||||
Facter.add(:puppet_server) do
|
||||
setcode do
|
||||
Facter::Util::PuppetSettings.with_puppet do
|
||||
Puppet[:server]
|
||||
end
|
||||
end
|
||||
end
|
11
environments/production/thirdparty/stdlib/lib/facter/root_home.rb
vendored
Normal file
11
environments/production/thirdparty/stdlib/lib/facter/root_home.rb
vendored
Normal file
|
@ -0,0 +1,11 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
Facter.add(:root_home) do
|
||||
setcode do
|
||||
require 'etc'
|
||||
rescue LoadError
|
||||
# Unavailable on platforms like Windows
|
||||
else
|
||||
Etc.getpwnam('root')&.dir
|
||||
end
|
||||
end
|
19
environments/production/thirdparty/stdlib/lib/facter/service_provider.rb
vendored
Normal file
19
environments/production/thirdparty/stdlib/lib/facter/service_provider.rb
vendored
Normal file
|
@ -0,0 +1,19 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Fact: service_provider
|
||||
#
|
||||
# Purpose: Returns the default provider Puppet will choose to manage services
|
||||
# on this system
|
||||
#
|
||||
# Resolution: Instantiates a dummy service resource and return the provider
|
||||
#
|
||||
# Caveats:
|
||||
#
|
||||
require 'puppet/type'
|
||||
require 'puppet/type/service'
|
||||
|
||||
Facter.add(:service_provider) do
|
||||
setcode do
|
||||
Puppet::Type.type(:service).newservice(name: 'dummy')[:provider].to_s
|
||||
end
|
||||
end
|
18
environments/production/thirdparty/stdlib/lib/facter/util/puppet_settings.rb
vendored
Normal file
18
environments/production/thirdparty/stdlib/lib/facter/util/puppet_settings.rb
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# A method to evaluate a Facter code block if puppet is loaded.
|
||||
module Facter::Util::PuppetSettings
|
||||
# This method is intended to provide a convenient way to evaluate a
|
||||
# Facter code block only if Puppet is loaded. This is to account for the
|
||||
# situation where the fact happens to be in the load path, but Puppet is
|
||||
# not loaded for whatever reason. Perhaps the user is simply running
|
||||
# facter without the --puppet flag and they happen to be working in a lib
|
||||
# directory of a module.
|
||||
def self.with_puppet
|
||||
Module.const_get(:Puppet)
|
||||
rescue NameError
|
||||
nil
|
||||
else
|
||||
yield
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue