Sha256: 51edb0da226df22be1e61fe9f2d0b44657cdc106c0cc91e4ef1357cc77ff6444

Contents?: true

Size: 1.45 KB

Versions: 19

Compression:

Stored size: 1.45 KB

Contents

# frozen_string_literal: true

require 'bolt/error'

# Removes a target from the specified inventory group.
#
# The target is removed from all child groups and all parent groups where the target has
# not been explicitly defined. A target cannot be removed from the `all` group.
#
# > **Note:** Not available in apply block
Puppet::Functions.create_function(:remove_from_group) do
  # @param target A pattern identifying a single target.
  # @param group The name of the group to remove the target from.
  # @example Remove Target from group.
  #   remove_from_group('foo@example.com', 'group1')
  # @example Remove failing Targets from the rest of a plan
  #   $result = run_command(uptime, my_group, '_catch_errors' => true)
  #   $result.error_set.targets.each |$t| { remove_from_group($t, my_group) }
  #   run_command(next_command, my_group) # does not target the failing nodes.
  dispatch :remove_from_group do
    param 'Boltlib::TargetSpec', :target
    param 'String[1]', :group
  end

  def remove_from_group(target, group)
    unless Puppet[:tasks]
      raise Puppet::ParseErrorWithIssue
        .from_issue_and_stack(Bolt::PAL::Issues::PLAN_OPERATION_NOT_SUPPORTED_WHEN_COMPILING,
                              action: 'remove_from_group')
    end

    inventory = Puppet.lookup(:bolt_inventory)
    executor = Puppet.lookup(:bolt_executor)
    executor.report_function_call(self.class.name)

    inventory.remove_from_group(inventory.get_targets(target), group)
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
bolt-2.15.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.14.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.13.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.12.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.11.1 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.11.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.10.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.9.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.8.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.7.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.6.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.5.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.4.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.3.1 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.3.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.2.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.1.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.0.1 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb
bolt-2.0.0 bolt-modules/boltlib/lib/puppet/functions/remove_from_group.rb