dpeters / puppet-opsview

Puppet types/providers to support Opsview resources
12 stars 10 forks source link

opsview_monitored: absent on ensure: undefined method `destroy' #7

Open antaflos opened 12 years ago

antaflos commented 12 years ago

Hi,

I know this is a known issue, i.e. the opsview_* types don't support ensure => 'absent'. But we are, once again, trying to get Puppet and Opsview to play nice together, and have been bitten by this the other day, so I thought I'd report this issue here. We are trying to dynamically add and remove monitored devices and thus kind of need on a working ensure => 'absent' for at least the opsview_monitored type.

Unfortunately we can't really contribute code as we are are not a Ruby shop in any way.

dpeters commented 12 years ago

I don't think this should be too hard, so I'll take a look and see if I can come up with something. One workaround you might be able to use in the meantime, would be to write a script that uses the opsview_rest tool to retrieve a server's ID and then delete it, something like this:

#!/bin/sh
monitored=$1
id=`opsview_rest --user=admin --password=initial --pretty --data-format=json GET "config/host?s.name=$monitored&cols=id" | grep id | awk -F\" '{print $4}'`
opsview_rest --user=admin --password=initial DELETE "config/host/$id"

You could then use the script via an exec in puppet.