1

I'm trying to use puppet's network device management feature to configure Cisco routers.

I know its just running ios commands so how can I extend it by having it run my own ios commands? I want to use this to create my own facts and do other stuff.

On a windows endpoint I can use exec to run shell commands:

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

How can I do something like this with puppet device?

When I tried running an ios command it gave me an error:

exec { 'test':
   command => 'show ip int bri'
}

Info: Caching catalog for 123.123.123.123
Error: Failed to apply catalog: Validation of Exec[test] failed: 'show ip int bri' is not qualified and no path was specified. Please qualify the command or specify a path. at /etc/puppet/environments/production/modules/ciscorouterconfig/manifests/init.pp:82
shell returned 1
red888
  • 4,069
  • 16
  • 58
  • 104
  • I'm going to ask this question differently in SO because maybe this is more developer oriented. – red888 Dec 21 '15 at 13:45

2 Answers2

1

The inner workings of the device resource types are inaccessible at the manifest level. The interface and vlan types abstracts it all away.

To add functionality, you will actually need to add your own types and providers. This requires some substantial Ruby hacking. If you feel up to it, you will want to look at

  1. the existing type code (interface and vlan)
  2. the existing providers (interface and vlan)
  3. their base provider which is just a thin layer around
  4. Puppet's cisco support code

It will likely be difficult to cram any extensions to this into a module, so it might be more straight forward to actually maintain your own branch of Puppet itself and then try to get it merged upstream.

Felix Frank
  • 3,063
  • 1
  • 15
  • 22
0

You can try to run the command without shortening like: show ip interface ..., and if you still get the same error then, I suspect that, it is not impelmented by puppet-device. Although it is a similar implementation like for a linux or windows box but it has a very limited capability.

The error you are getting also sounds like the command is not available.

If you read the man page it clearly says:

Retrieves all configurations from the puppet master and apply them to the remote devices configured in /etc/puppetlabs/puppet/device.conf.

Under OPTIONS you can read:

Note that any setting that's valid in the configuration file is also a valid long argument. For example, 'server' is a valid configuration parameter, so you can specify '--server servername' as an argument.

sh ip ... is not a configuration command or option that you can apply and I guess you won't be able to execute it like this.

Diamond
  • 8,791
  • 3
  • 22
  • 37
  • Well I know I can't use it like this the question was where do I go to extended it? How can I make it send my own commands? I have my device/auth settings in device.conf now how can I use that same connection info and send my own commands? – red888 Dec 20 '15 at 16:55