Puppet resource command called munge

I created a puppet resource for interfaces. Most of the interface names on my switch are in lowercase, with the exception of Ethernet interfaces, so I jotted down the interface name to hopefully reduce errors in the manifest; eg:.

manifest:

  cisco_interface { 'Ethernet1/1': description => 'foo' }

      

type / cisco_interface.rb:

  newparam(:name) do
    munge { |value|
      value.downcase
    }  
  end 

      

My provider code also minifies the interface names when I collect the interface list with self.instances.

Ok, so this works great when I test the manifest, but not that good with the puppet resource command, which only works when I call it with the name already folded:

switch# puppet resource cisco_interface 'Ethernet1/1'
cisco_interface { 'Ethernet1/1':
  ensure => 'absent',
}

switch# puppet resource cisco_interface 'ethernet1/1'
cisco_interface { 'ethernet1/1':
  ensure                       => 'present',
  description                  => 'foo',
}

      

The command name field for a puppet resource looks like just a simple filter, so I think I'm stuck, but I thought I saw other resource types throwing such name values.

Is it possible to change the header values ​​in a way that works for both scenarios? If not, then I'm not sure if it would be better to keep it case-sensitive, as this is what users will see in the switch configuration, or to "help" them avoid errors in the manifest.

+3


source to share


1 answer


You're right about what's going on here, the puppet currently requires the name passed on the command line to match the name exactly as per the type. He buried a couple of levels deep, but look at the methods find

and resource_name

RAL .



It seems to me that this would not be a major change, so you may need to file a defect or make changes yourself!

+1


source







All Articles