Puppet Function: peadm::plan_step

Defined in:
lib/puppet/functions/peadm/plan_step.rb
Function type:
Ruby 4.x API

Overview

peadm::plan_step(String $step_name, Callable &$block)Any

Parameters:

  • step_name (String)
  • &block (Callable)

Returns:

  • (Any)


3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/puppet/functions/peadm/plan_step.rb', line 3

Puppet::Functions.create_function(:'peadm::plan_step', Puppet::Functions::InternalFunction) do
  dispatch :plan_step do
    scope_param
    param 'String', :step_name
    block_param
  end

  def plan_step(scope, step_name)
    first_step = scope.bound?('begin_at_step') ? scope['begin_at_step'] : nil
    first_step_reached = if first_step.nil? || scope.bound?('__first_plan_step_reached__')
                           true
                         elsif step_name == first_step
                           scope['__first_plan_step_reached__'] = true
                         else
                           false
                         end

    if first_step_reached
      call_function('out::message', "# Plan Step: #{step_name}")
      yield
    else
      call_function('out::message', "# Plan Step: #{step_name} - SKIPPING")
    end
  end
end