Skip to content

Support tags on apply blocks #3371

@puppetjoy

Description

@puppetjoy

Use Case

Tags are a core feature of Puppet. I use them to filter resources in a catalog to optimize long builds.

Describe the Solution You Would Like

Both bolt apply and the apply function take parameters to enable noop mode. It should be extended to take a tags parameter.

Describe Alternatives You've Considered

I considered refactoring my code to eliminate tags, but my use case doesn't support that. For workarounds, I tried setting the global tags setting like:

run_command('puppet config set tags foo', $target)
apply($target) { include module }
run_command('puppet config delete tags', $target)

and though I could see the tags = foo setting present on the target's main puppet.conf, it did not take effect during the apply block. A "working" but ugly workaround was to configure tags directly in the interpreter:

inventory.yaml

config:
  podman:
    interpreters:
      rb: ['/usr/bin/ruby', '-r', 'puppet', '-e', 'Puppet[:tags] = File.open("/.apply_tags", &:gets) if File.exist? "/.apply_tags"; load ARGV.shift']
run_command('sh -c "echo foo > /.apply_tags"', $target, 'Set Puppet tags')
apply($target) { include module }
run_command('rm /.apply_tags', $target, 'Clear Puppet tags')

Metadata

Metadata

Assignees

No one assigned

    Labels

    FeatureNew features and improvements.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions