Skip to content

Commit 0e0535b

Browse files
committed
(PUP-8766) add libdir option for puppet device
This allows overriding the per-device libdir to enable local and testing scenarios where pluginsync doesn't make sense.
1 parent 138b5d0 commit 0e0535b

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

lib/puppet/application/device.rb

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ def preinit
5454
options[:detailed_exitcodes] = true
5555
end
5656

57+
option("--libdir LIBDIR") do |arg|
58+
options[:libdir] = arg
59+
end
60+
5761
option("--apply MANIFEST") do |arg|
5862
options[:apply] = arg.to_s
5963
end
@@ -97,6 +101,7 @@ def help
97101
puppet device [-h|--help] [-v|--verbose] [-d|--debug]
98102
[-l|--logdest syslog|<file>|console] [--detailed-exitcodes]
99103
[--deviceconfig <file>] [-w|--waitforcert <seconds>]
104+
[--libdir <directory>]
100105
[-a|--apply <file>] [-f|--facts] [-r|--resource <type> [name]]
101106
[-t|--target <device>] [--user=<user>] [-V|--version]
102107
@@ -173,6 +178,10 @@ def help
173178
certificate request. This is useful for the initial setup of a target.
174179
You can turn off waiting for certificates by specifying a time of 0.
175180
181+
* --libdir:
182+
Override the per-device libdir with a local directory. Specifying a libdir also
183+
disables pluginsync. This is useful for testing.
184+
176185
* --apply:
177186
Apply a manifest against a remote target. Target must be specified.
178187
@@ -253,11 +262,11 @@ def main
253262

254263
# override local $vardir and $certname
255264
Puppet[:confdir] = ::File.join(Puppet[:devicedir], device.name)
256-
Puppet[:libdir] = ::File.join(Puppet[:devicedir], device.name, 'lib')
265+
Puppet[:libdir] = options[:libdir] || ::File.join(Puppet[:devicedir], device.name, 'lib')
257266
Puppet[:vardir] = ::File.join(Puppet[:devicedir], device.name)
258267
Puppet[:certname] = device.name
259268

260-
unless options[:resource] || options[:facts] || options[:apply]
269+
unless options[:resource] || options[:facts] || options[:apply] || options[:libdir]
261270
Puppet::Configurer::PluginHandler.new.download_plugins(env)
262271
end
263272
# this init the device singleton, so that the facts terminus

spec/unit/application/device_spec.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,7 @@
299299
@device.options.stubs(:[]).with(:facts).returns(false)
300300
@device.options.stubs(:[]).with(:resource).returns(false)
301301
@device.options.stubs(:[]).with(:to_yaml).returns(false)
302+
@device.options.stubs(:[]).with(:libdir).returns(nil)
302303
@device.options.stubs(:[]).with(:client)
303304
@device.command_line.stubs(:args).returns([])
304305
Puppet::Util::NetworkDevice::Config.stubs(:devices).returns({})

0 commit comments

Comments
 (0)