Sha256: ec08e4165481a4f867b95e92528bb597f23d08978e629fbad5e27efe93462a25
Contents?: true
Size: 1.36 KB
Versions: 2
Compression:
Stored size: 1.36 KB
Contents
# Runs the `plan` referenced by its name passing giving arguments to it given as a hash of name to value mappings. # A plan is autoloaded from under <root>/plans if not already defined. # # @example defining and running a plan # plan myplan($x) { # # do things with tasks # notice "plan done with param x = ${x}" # } # run_plan('myplan', {x => 'testing' } # Puppet::Functions.create_function(:run_plan, Puppet::Functions::InternalFunction) do dispatch :run_plan do scope_param param 'String', :plan_name optional_param 'Hash', :named_args end def run_plan(scope, plan_name, named_args = {}) unless Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: 'run_plan' ) end loaders = closure_scope.compiler.loaders # The perspective of the environment is wanted here (for now) to not have to # require modules to have dependencies defined in meta data. loader = loaders.private_environment_loader if loader && (func = loader.load(:plan, plan_name)) # TODO: Add profiling around this return func.class.dispatcher.dispatchers[0].call_by_name_with_scope(scope, named_args, true) end # Could not find plan raise ArgumentError, "Function #{self.class.name}(): Unknown plan: '#{plan_name}'" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
bolt-0.10.0 | modules/boltlib/lib/puppet/functions/run_plan.rb |
bolt-0.9.0 | modules/boltlib/lib/puppet/functions/run_plan.rb |