Skip to content

Commit 10c0219

Browse files
committed
Add options for failing resource check on command line
1 parent bd929dd commit 10c0219

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/puppet/application/resource.rb

+6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ def preinit
1515
option("--verbose", "-v")
1616
option("--edit", "-e")
1717
option("--to_yaml", "-y")
18+
option('--fail-when-not-found', '-f')
1819

1920
option("--types", "-t") do |_arg|
2021
env = Puppet.lookup(:environments).get(Puppet[:environment]) || create_default_environment
@@ -109,6 +110,10 @@ def help
109110
Output found resources in yaml format, suitable to use with Hiera and
110111
create_resources.
111112
113+
* --fail-when-not-found:
114+
Fails and returns an exit code if the resource is not found, valid only
115+
for Windows and SystemD services.
116+
112117
EXAMPLE
113118
-------
114119
This example uses `puppet resource` to return a Puppet configuration for
@@ -238,6 +243,7 @@ def find_or_save_resources(type, name, params)
238243
# save returns [resource that was saved, transaction log from applying the resource]
239244
save_result, report = Puppet::Resource.indirection.save(resource, key)
240245
status = report.resource_statuses[resource.ref]
246+
binding.irb
241247
raise "Failed to manage resource #{resource.ref}" if status&.failed?
242248

243249
[save_result]

0 commit comments

Comments
 (0)