Search code examples
rubypuppetpuppet-enterprise

How can I make Puppet Device Management send my own commands?


I'm using puppet's network device management feature to configure Cisco routers, but I don't know how I can use it to send my own commands which I also want to use to create my own facts.

For regular Windows or Linux clients we have exec:

exec { 'test':
      command => 'C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy remotesigned -file C:\test.ps1',
    }

And to use it with factor:

Facter.add('hardware_platform') do
  setcode do
    Facter::Core::Execution.exec('/bin/uname --hardware-platform')
  end
end

But what is the equivalent for device management?

Looking at the code on github it looks like these might be the relevant classes: puppet/lib/puppet/util/network_device/transport/ssh.rb and telnet.rb

But I don't know how I should be calling and using them in my modules.


Solution

  • As I also answered you over on puppet-users, there is no mechanism in the Puppet DSL view of the core data types or in the puppet device endpoint that would allow you to hook into the underlying communication between node and network device to inject arbitrary IOS commands. To get at that layer you would need to write a custom type and provider, or possibly to modify one of the core types.