Sha256: 6048e4c80ea0d95083a6536a22062759eecb9627d3ccdc75ac2a96a62841a9ee

Contents?: true

Size: 1.3 KB

Versions: 70

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'bolt/error'

# Sets a particular feature to present on a target.
#
# Features are used to determine what implementation of a task should be run.
# Supported features are:
# - `powershell`
# - `shell`
# - `puppet-agent`
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:set_feature) do
  # @param target The Target object to add features to. See {get_targets}.
  # @param feature The string identifying the feature.
  # @param value Whether the feature is supported.
  # @return The target with the updated feature
  # @example Add the `puppet-agent` feature to a target
  #   set_feature($target, 'puppet-agent', true)
  dispatch :set_feature do
    param 'Target', :target
    param 'String', :feature
    optional_param 'Boolean', :value
    return_type 'Target'
  end

  def set_feature(target, feature, value = true)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING, action: 'set_feature')
    end

    inventory = Puppet.lookup(:bolt_inventory)
    executor = Puppet.lookup(:bolt_executor)
    # Send Analytics Report
    executor.report_function_call(self.class.name)

    inventory.set_feature(target, feature, value)

    target
  end
end

Version data entries

70 entries across 70 versions & 1 rubygems

Version Path
bolt-2.24.1 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.24.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.23.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.22.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.21.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.20.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.19.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.18.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.17.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb
bolt-2.16.0 bolt-modules/boltlib/lib/puppet/functions/set_feature.rb