Method: Puppet::Pal.in_tmp_environment
- Defined in:
- lib/puppet/pal/pal_impl.rb
.in_tmp_environment(env_name, modulepath: [], settings_hash: {}, facts: nil, variables: {}) {|context,| ... } ⇒ Object
Defines the context in which to perform puppet operations (evaluation, etc) The code to evaluate in this context is given in a block.
230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 |
# File 'lib/puppet/pal/pal_impl.rb', line 230 def self.in_tmp_environment(env_name, modulepath: [], settings_hash: {}, facts: nil, variables: {}, &block) assert_non_empty_string(env_name, _("temporary environment name")) # TRANSLATORS: do not translate variable name string in these assertions assert_optionally_empty_array(modulepath, 'modulepath') unless block_given? raise ArgumentError, _("A block must be given to 'in_tmp_environment'") # TRANSLATORS 'in_tmp_environment' is a name, do not translate end env = Puppet::Node::Environment.create(env_name, modulepath) in_environment_context( Puppet::Environments::Static.new(env), # The tmp env is the only known env env, facts, variables, &block ) end |