Skip to content

Commit 138b5d0

Browse files
committed
(PUP-8766) Enable early pluginsync for puppet device agent mode
When running `puppet device` in agent mode, a pluginsync needs to happen before the device is loaded. For the non-agent modes `--facts`, `--resource`, and `--apply`, doing no pluginsync is useful since they are used in local workflows (like testing), and for a quicker turnaround when exploring devices.
1 parent 823a6c7 commit 138b5d0

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

lib/puppet/application/device.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
require 'puppet/application'
2+
require 'puppet/configurer'
23
require 'puppet/util/network_device'
34

45
class Puppet::Application::Device < Puppet::Application
@@ -256,6 +257,9 @@ def main
256257
Puppet[:vardir] = ::File.join(Puppet[:devicedir], device.name)
257258
Puppet[:certname] = device.name
258259

260+
unless options[:resource] || options[:facts] || options[:apply]
261+
Puppet::Configurer::PluginHandler.new.download_plugins(env)
262+
end
259263
# this init the device singleton, so that the facts terminus
260264
# and the various network_device provider can use it
261265
Puppet::Util::NetworkDevice.init(device)

spec/unit/application/device_spec.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,9 @@
504504
expect { @device.main }.to exit_with 1
505505
end
506506

507-
it "should print the device url scheme, host, and port" do
507+
it "should retrieve plugins and print the device url scheme, host, and port" do
508+
Puppet.stubs(:info)
509+
Puppet.expects(:info).with "Retrieving pluginfacts"
508510
Puppet.expects(:info).with "starting applying configuration to device1 at ssh://testhost"
509511
Puppet.expects(:info).with "starting applying configuration to device2 at https://testhost:443/some/path"
510512
expect { @device.main }.to exit_with 1

0 commit comments

Comments
 (0)