Puppet Function: choria::playbook_exist
- Defined in:
- lib/puppet/functions/choria/playbook_exist.rb
- Function type:
- Ruby 4.x API
Overview
Checks if the Choria playbook present
This function tries to load Choria playbook and returns true if playbook exists (regardless can it be parsed or not). False is returned otherwise.
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/puppet/functions/choria/playbook_exist.rb', line 10 Puppet::Functions.create_function(:"choria::playbook_exist", Puppet::Functions::InternalFunction) do dispatch :playbook_exist do scope_param param "String", :playbook end def playbook_exist(scope, playbook) unless Puppet[:tasks] raise Puppet::ParseErrorWithIssue.from_issue_and_stack( Puppet::Pops::Issues::TASK_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, operation: "playbook_exist" ) end loaders = closure_scope.compiler.loaders loader = loaders.private_environment_loader begin if loader && (func = loader.load(:plan, playbook)) return true end rescue ArgumentError, Puppet::Error return true # Return true if not parseable too (as it exists) end false end end |