Module: PuppetDebugger::Support::Environment
- Included in:
- PuppetDebugger::Support
- Defined in:
- lib/puppet-debugger/support/environment.rb
Instance Method Summary collapse
- #bolt_modules ⇒ Object
-
#create_environment ⇒ Object
returns the environment.
- #create_node_environment(manifest = nil) ⇒ Object
- #default_manifests_dir ⇒ Object
-
#default_modules_paths ⇒ Object
returns an array of module directories, generally this is the only place to look for puppet code by default.
-
#default_puppet_env_name ⇒ Object
the cached name of the environment.
- #default_site_manifest ⇒ Object
-
#environment_loaders ⇒ Object
currently this is not being used.
-
#modules_paths ⇒ Object
returns all the modules paths defined in the environment.
- #puppet_env_name ⇒ Object
-
#puppet_environment ⇒ Object
(also: #environment)
creates a puppet environment given a module path and environment name this is cached.
- #set_environment(value) ⇒ Object
Instance Method Details
#bolt_modules ⇒ Object
24 25 26 27 |
# File 'lib/puppet-debugger/support/environment.rb', line 24 def bolt_modules spec = Gem::Specification.latest_specs.find { |spec| spec.name.eql?('bolt') } bolt_modules = File.join(spec.full_gem_path, 'bolt-modules') if spec end |
#create_environment ⇒ Object
returns the environment
43 44 45 46 47 |
# File 'lib/puppet-debugger/support/environment.rb', line 43 def create_environment Puppet::Node::Environment.create(Puppet[:environment], default_modules_paths, default_manifests_dir) end |
#create_node_environment(manifest = nil) ⇒ Object
49 50 51 52 |
# File 'lib/puppet-debugger/support/environment.rb', line 49 def create_node_environment(manifest = nil) env = Puppet.lookup(:current_environment) manifest ? env.override_with(manifest: manifest) : env end |
#default_manifests_dir ⇒ Object
34 35 36 |
# File 'lib/puppet-debugger/support/environment.rb', line 34 def default_manifests_dir File.join(Puppet[:environmentpath], Puppet[:environment], 'manifests') end |
#default_modules_paths ⇒ Object
returns an array of module directories, generally this is the only place to look for puppet code by default. This is read from the puppet configuration
15 16 17 18 19 20 21 22 |
# File 'lib/puppet-debugger/support/environment.rb', line 15 def default_modules_paths dirs = [] # add the puppet-debugger directory so we can load any defined functions dirs << File.join(Puppet[:environmentpath], default_puppet_env_name, 'modules') unless Puppet[:environmentpath].empty? dirs << Puppet.settings[:basemodulepath].split(File::PATH_SEPARATOR) dirs << bolt_modules dirs.flatten.compact end |
#default_puppet_env_name ⇒ Object
the cached name of the environment
63 64 65 |
# File 'lib/puppet-debugger/support/environment.rb', line 63 def default_puppet_env_name ENV['PUPPET_ENV'] || Puppet[:environment] end |
#default_site_manifest ⇒ Object
38 39 40 |
# File 'lib/puppet-debugger/support/environment.rb', line 38 def default_site_manifest File.join(default_manifests_dir, 'site.pp') end |
#environment_loaders ⇒ Object
currently this is not being used
68 69 70 |
# File 'lib/puppet-debugger/support/environment.rb', line 68 def environment_loaders name = compiler.loaders.public_environment_loader.loader_name end |
#modules_paths ⇒ Object
returns all the modules paths defined in the environment
30 31 32 |
# File 'lib/puppet-debugger/support/environment.rb', line 30 def modules_paths puppet_environment.full_modulepath end |
#puppet_env_name ⇒ Object
58 59 60 |
# File 'lib/puppet-debugger/support/environment.rb', line 58 def puppet_env_name puppet_environment.name end |
#puppet_environment ⇒ Object Also known as: environment
creates a puppet environment given a module path and environment name this is cached
8 9 10 |
# File 'lib/puppet-debugger/support/environment.rb', line 8 def puppet_environment @puppet_environment ||= create_environment end |
#set_environment(value) ⇒ Object
54 55 56 |
# File 'lib/puppet-debugger/support/environment.rb', line 54 def set_environment(value) @puppet_environment = value end |